API code examples
Call the Responses endpoint with JavaScript or Python.
Install Node.js LTS for the JavaScript example, or Python 3 for the Python example. These examples use built-in HTTP libraries and need no extra packages.
Set the API key environment variable in your terminal. Save one example below as request.mjs or request.py, replacing the model ID with a Responses-compatible model.
Run the matching file in the same terminal where you set the key. A returned message confirms the request; an HTTP error includes its status and response body.
Run these examples on your own computer or server. Never embed your API key in a public webpage or commit it to a repository. The environment variable lasts for the current terminal session.