Skip to content
Docs

AI Gateway OpenAI Reasoning

OpenAI reasoning models can think through problems before responding. You can control the depth of reasoning and receive summaries of the model's thought process. Each model supports different effort levels and defaults.

See the AI SDK OpenAI provider reference for supported reasoning options and response metadata.

To see the current list of OpenAI reasoning models, use the Reasoning filter on the AI Gateway models page.

Use GET /v1/models to find the model's reasoning_options entry with type: "effort" and read its values. This includes new model variants without relying on a family-wide support table. The catalog doesn't expose a structured default; consult the OpenAI model documentation when leaving effort unset.

Check the API-format mapping before passing a catalog value to a client. In particular, AI SDK 7's top-level reasoning option doesn't accept max, even when the catalog lists it for the model.

Set shared reasoning effort with the AI SDK 7 top-level reasoning option, which AI Gateway translates for the serving provider:

reasoning-effort.ts
import { generateText } from 'ai';
 
const result = await generateText({
  model: 'openai/gpt-6-astra',
  prompt: 'Tell me about the Mission burrito debate in San Francisco.',
  reasoning: 'high',
});
 
console.log(result.text);

Use providerOptions.openai when you need OpenAI-specific features like reasoning summaries. If you set reasoningEffort in providerOptions, it takes precedence over the top-level reasoning value.

Set reasoningSummary to receive the model's thought process as it streams. Different models support different summarizers. For example, o4-mini supports detailed summaries.

stream-reasoning.ts
import { streamText } from 'ai';
 
const result = streamText({
  model: 'openai/gpt-6-astra',
  prompt: 'Tell me about the Mission burrito debate in San Francisco.',
  providerOptions: {
    openai: {
      reasoningEffort: 'high',
      reasoningSummary: 'detailed', // 'auto' for condensed or 'detailed' for comprehensive
    },
  },
});
 
for await (const part of result.stream) {
  if (part.type === 'reasoning-delta') {
    process.stdout.write(part.text);
  } else if (part.type === 'text-delta') {
    process.stdout.write(part.text);
  }
}
stream-reasoning.ts
import { streamText } from 'ai';
 
const result = streamText({
  model: 'openai/gpt-6-astra',
  prompt: 'Tell me about the Mission burrito debate in San Francisco.',
  providerOptions: {
    openai: {
      reasoningEffort: 'high',
      reasoningSummary: 'detailed', // 'auto' for condensed or 'detailed' for comprehensive
    },
  },
});
 
for await (const part of result.fullStream) {
  if (part.type === 'reasoning-delta') {
    process.stdout.write(part.text);
  } else if (part.type === 'text-delta') {
    process.stdout.write(part.text);
  }
}

For non-streaming calls, reasoning summaries are available in the reasoning field:

generate-reasoning.ts
import { generateText } from 'ai';
 
const result = await generateText({
  model: 'openai/gpt-6-astra',
  prompt: 'Tell me about the Mission burrito debate in San Francisco.',
  providerOptions: {
    openai: {
      reasoningEffort: 'high',
      reasoningSummary: 'auto',
    },
  },
});
 
console.log('Reasoning:', result.reasoningText);

You can set reasoning effort without the AI SDK through the gateway's OpenAI-compatible endpoints:

reasoning-chat-completions.ts
import OpenAI from 'openai';
 
const openai = new OpenAI({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh/v1',
});
 
const completion = await openai.chat.completions.create({
  model: 'openai/gpt-6-astra',
  messages: [
    {
      role: 'user',
      content: 'Tell me about the Mission burrito debate in San Francisco.',
    },
  ],
  // AI Gateway extension fields are not included in the upstream SDK types.
  ...{
    reasoning: {
      effort: 'high',
    },
  },
});
 
const message = completion.choices[0].message;
console.log(
  'Reasoning:',
  'reasoning' in message ? message.reasoning : undefined,
);
console.log('Answer:', completion.choices[0].message.content);
reasoning_chat_completions.py
import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.getenv('AI_GATEWAY_API_KEY'),
    base_url='https://ai-gateway.vercel.sh/v1'
)
 
completion = client.chat.completions.create(
    model='openai/gpt-6-astra',
    messages=[
        {
            'role': 'user',
            'content': 'Tell me about the Mission burrito debate in San Francisco.'
        }
    ],
    extra_body={
        'reasoning': {
            'effort': 'high'
        }
    }
)
 
print('Reasoning:', completion.choices[0].message.reasoning)
print('Answer:', completion.choices[0].message.content)
reasoning-chat-completions.sh
curl https://ai-gateway.vercel.sh/v1/chat/completions \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-6-astra",
    "messages": [
      {
        "role": "user",
        "content": "Tell me about the Mission burrito debate in San Francisco."
      }
    ],
    "reasoning": {
      "effort": "high"
    }
  }'

The Responses API also supports the reasoning object, including the summary option for reasoning summaries.

Set reasoningEffort in providerOptions.openai, or use the top-level reasoning option for shared effort. Select a model-supported level from the catalog and check the AI SDK OpenAI provider options for values your installed SDK accepts.

Provider-specific options take precedence over the shorthand. Don't infer supported values or defaults from a different model in the same family.

ValueDescription
autoCondensed reasoning summary
detailedComprehensive reasoning summary
conciseBrief reasoning summary

Set a supported effort explicitly if you need reasoning enabled. Requesting a summary alone doesn't establish the model's effort or guarantee summary text.

For more details, see the OpenAI reasoning docs.

Last updated September 8, 2026

Was this helpful?

supported.