Call an OpenAI model with the Responses API
Install the openai package for Python or JavaScript, export OPENAI_API_KEY and make a first Responses API request with gpt-6-astra, as shown in OpenAI's Developer quickstart.
Verification
- Test environment
- Unknown
- Tested on
- Unknown
- Last updated
- 2026-11-11
Related models: GPT-6 Luna, GPT-6 Astra, GPT-6.1 Sol
This guide follows OpenAI's official Developer quickstart. The samples are copied from that page; we have not run them ourselves.
1. Create and export an API key
Create a key on the API keys page, then export it. Every OpenAI SDK reads OPENAI_API_KEY from the environment.
macOS / Linux:
export OPENAI_API_KEY="your_api_key_here"
Windows (PowerShell):
setx OPENAI_API_KEY "your_api_key_here"
2. JavaScript (Node.js, Deno or Bun)
npm install openai
Save this as example.mjs and run node example.mjs:
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-6-astra",
input: "Write a one-sentence bedtime story about a unicorn.",
});
console.log(response.output_text);
3. Python
pip install openai
Save this as example.py and run python example.py:
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-6-astra",
input="Write a one-sentence bedtime story about a unicorn.",
)
print(response.output_text)
4. How the Responses API differs
- You send
input(a string, or a list of messages and content parts) rather than amessagesarray. - The response holds a list of output items. The SDKs add the
output_textconvenience property, which joins the text output for you. - The same endpoint accepts images: the quickstart's next example passes an
inputlist with aninput_textpart and aninput_imagepart. - Streaming uses typed, semantic events such as
response.output_text.delta(see the streaming guide on this site).
5. Choose a model
The quickstart uses gpt-6-astra, at the time of writing the most expensive OpenAI model on this site's Pricing page. Other OpenAI models listed here:
- GPT-6 Astra:
gpt-6-astra - GPT-6.1 Sol:
gpt-6.1-sol - GPT-6 Luna:
gpt-6-luna
Change only the model string to switch. Check each model page for context window and features, and the Pricing page for what your workload would cost.
Further reading
- ChatGPT Plus vs Claude Pro: A Month of Token Usage Compared: how much GPT-6.1 usage a ChatGPT Plus subscription covered in Codex over one month.
Sources
- Developer quickstart (OpenAI API docs)developers
.openai .com (opens in a new tab) · checked 2026-11-11 - ChatGPT Plus vs Claude Pro: A Month of Token Usage Compared (XMLans blog)en
.xmlans .com (opens in a new tab) · checked 2026-11-11 - ChatGPT vs Claude 20刀订阅大横评(星梦博客)www
.xmlans .com (opens in a new tab) · checked 2026-11-11