AI Gateway Amazon Bedrock Reasoning
Amazon Bedrock exposes Anthropic Claude reasoning through model-creator-specific provider options. Configuration depends on the model:
- Adaptive reasoning: Set
reasoningConfig: { type: 'adaptive', maxReasoningEffort }. Available on Claude 4.6 and later. Required on Claude Opus 4.7 and later, where the legacytype: 'enabled'mode returns a 400 error. - Manual reasoning: Set
reasoningConfig: { type: 'enabled', budgetTokens: N }for a fixed token budget. Available on Claude 4.6 and earlier (deprecated on 4.6, removed on Claude Opus 4.7 and later).
See the AI SDK Amazon Bedrock provider reference for supported reasoning options and response metadata.
Use GET /v1/models to discover a model's reasoning controls. Then use model endpoints or the Bedrock model filter to check which models Bedrock serves. The model catalog's creator slug remains unchanged when you route through Bedrock.
Keep the adaptive and legacy request shapes above separate. Catalog metadata describes model controls; the serving provider can impose additional restrictions.
The AI SDK 7 top-level reasoning option works with Bedrock-hosted Claude models without provider-specific configuration. On Claude 4.6 and later it maps to adaptive reasoning at the corresponding effort level:
import { generateText } from 'ai';
const result = await generateText({
model: 'anthropic/claude-opus-5',
prompt: 'How many "r"s are in the word "strawberry"?',
reasoning: 'high',
});
console.log(result.text);This is especially useful with provider fallbacks: the same setting applies whether Anthropic, Bedrock, or Vertex serves the request. Use providerOptions.bedrock when you need an exact token budget on older models. If you set reasoningConfig in providerOptions, it takes precedence over the top-level reasoning value.
import { generateText } from 'ai';
const result = await generateText({
model: 'anthropic/claude-opus-5',
prompt: 'How many "r"s are in the word "strawberry"?',
providerOptions: {
bedrock: {
reasoningConfig: { type: 'adaptive', maxReasoningEffort: 'max' },
},
},
});
console.log(result.reasoningText);
console.log(result.text);For pre-4.7 models, use type: 'enabled' with a budgetTokens value. This is the only reasoning mode supported on Claude 4.5 and earlier; on Claude 4.6 it works but is deprecated; on Claude Opus 4.7 and later it returns a 400 error.
import { generateText } from 'ai';
const result = await generateText({
model: 'anthropic/claude-sonnet-4.5',
prompt: 'How many people will live in the world in 2040?',
providerOptions: {
bedrock: {
reasoningConfig: { type: 'enabled', budgetTokens: 2048 },
},
},
});
console.log(result.reasoningText);
console.log(result.text);You can configure reasoning without the AI SDK through the gateway's OpenAI-compatible endpoints. Use providerOptions.gateway.order to route the request to Bedrock; AI Gateway maps the reasoning effort level to Bedrock's reasoning configuration:
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: 'anthropic/claude-opus-5',
messages: [
{
role: 'user',
content: 'How many "r"s are in the word "strawberry"?',
},
],
// AI Gateway extension fields are not included in the upstream SDK types.
...{
reasoning: {
effort: 'high',
},
},
...{
providerOptions: {
gateway: {
order: ['bedrock'],
},
},
},
});
const message = completion.choices[0].message;
console.log(
'Reasoning:',
'reasoning' in message ? message.reasoning : undefined,
);
console.log('Answer:', completion.choices[0].message.content);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='anthropic/claude-opus-5',
messages=[
{
'role': 'user',
'content': 'How many "r"s are in the word "strawberry"?'
}
],
extra_body={
'reasoning': {
'effort': 'high'
},
'providerOptions': {
'gateway': {
'order': ['bedrock']
}
}
}
)
print('Reasoning:', completion.choices[0].message.reasoning)
print('Answer:', completion.choices[0].message.content)curl https://ai-gateway.vercel.sh/v1/chat/completions \
-H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-opus-5",
"messages": [
{
"role": "user",
"content": "How many \"r\"s are in the word \"strawberry\"?"
}
],
"reasoning": {
"effort": "high"
},
"providerOptions": {
"gateway": {
"order": ["bedrock"]
}
}
}'| Parameter | Type | Description |
|---|---|---|
type | string | Set to 'adaptive' |
maxReasoningEffort | string | A level supported by the model's catalog entry and the Bedrock provider options |
| Parameter | Type | Description |
|---|---|---|
type | string | Set to 'enabled' |
budgetTokens | number | Token budget for reasoning. Minimum: 1,024. Maximum: 64,000 |
Was this helpful?