OpenAI Responses Reasoning with AI Gateway
For models that support reasoning, set the reasoning parameter to control how much effort the model spends thinking:
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.AI_GATEWAY_API_KEY,
baseURL: 'https://ai-gateway.vercel.sh/v1',
});
const response = await client.responses.create({
model: 'anthropic/claude-sonnet-5',
input: 'Explain the Monty Hall problem step by step.',
reasoning: {
effort: 'high',
},
max_output_tokens: 2048,
});
console.log(response.output_text);import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv('AI_GATEWAY_API_KEY'),
base_url='https://ai-gateway.vercel.sh/v1',
)
response = client.responses.create(
model='anthropic/claude-sonnet-5',
input='Explain the Monty Hall problem step by step.',
reasoning={
'effort': 'high',
},
max_output_tokens=2048,
)
print(response.output_text)curl -X POST "https://ai-gateway.vercel.sh/v1/responses" \
-H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"input": "Explain the Monty Hall problem step by step.",
"reasoning": {
"effort": "high"
},
"max_output_tokens": 2048
}'Use catalog discovery to find the selected model's reasoning_options. The HTTP request schema accepts none, minimal, low, medium, high, xhigh, and max, but each model supports its own subset. Don't infer defaults from a model family.
OpenAI models can use native Responses routing; other models use OpenResponses. Cross-provider translation can map effort to a different native level or a token budget. AI SDK 7's shorthand doesn't accept max; see the format mapping.
To inspect reasoning, check returned usage and reasoning items where available. A successful answer or an echoed reasoning.effort value alone doesn't prove the provider applied that exact level.
Was this helpful?