1. Install the SDK

Shell
npm install openai

2. Set your API key

Shell
export OPENAI_API_KEY="your_api_key"

3. Send a request

JavaScript
import OpenAI from "openai";

const client = new OpenAI();

const response = await client.responses.create({
  model: "gpt-6-astra",
  input: "Explain three practical uses of long-context reasoning."
});

console.log(response.output_text);

The example uses OpenAI’s recommended Responses API and the model ID gpt-6-astra.

Increase reasoning effort when needed

JavaScript
const response = await client.responses.create({
  model: "gpt-6-astra",
  reasoning: { effort: "high" },
  input: "Review this migration plan and identify hidden failure modes."
});

Production checklist

  • Handle rate-limit and transient server errors.
  • Stream output for long interactive responses where appropriate.
  • Track cost and token usage separately from application latency.
  • Use tool calls only when the workflow benefits from them.

Primary sources

Specifications and prices can change. We prefer first-party documentation and record the date each page was reviewed.

  1. OpenAI Developers — GPT-6 Astra model page
  2. OpenAI Developers — Model guidance