Skip to content

Bug: @ai-sdk/amazon-bedrock sends 'reasoningConfig' (camelCase) but AWS Bedrock expects 'reasoning_effort' (snake_case) #11467

@nabilfreeman

Description

@nabilfreeman

Description

The @ai-sdk/amazon-bedrock package has a parameter naming bug that causes validation errors when using reasoning effort with OpenAI and possibly other non-Anthropic models (e.g., GPT-OSS models on AWS Bedrock).

The Problem

When setting reasoning effort for OpenAI models, the SDK sends reasoningConfig (camelCase) to AWS Bedrock, but the API expects reasoning_effort (snake_case).

Error message:

{
  "code": "validation_error",
  "message": "Failed to deserialize the JSON body into the target type: unknown variant 'reasoningConfig', expected one of 'audio', 'frequency_penalty', ..., 'reasoning_effort', ...",
  "type": "invalid_request_error"
}

Root Cause

Location: node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs:795-807

The bug was introduced in v3.0.66 with the feature "Support Nova 2 extended reasoning 'maxReasoningEffort' field".

For non-Anthropic models, the code does:

const maxReasoningEffort = bedrockOptions.reasoningConfig?.maxReasoningEffort;
if (maxReasoningEffort != null && !isAnthropicModel) {
  return {
    ...bedrockOptions.additionalModelRequestFields,
    reasoningConfig: {  // BUG: Should be reasoning_effort
      maxReasoningEffort: maxReasoningEffort
    }
  };
}

Reproduction Steps

  1. Initialize a OpenAI model (e.g., GPT-OSS) with reasoning configuration:
import { bedrock } from '@ai-sdk/amazon-bedrock';

const model = bedrock('openai.gpt-oss-120b-1:0', {
  reasoningConfig: {
    type: 'enabled',
    maxReasoningEffort: 'medium'
  }
});
  1. Call the model
  2. Observe validation error from AWS Bedrock API

Expected Behavior

The SDK should send reasoning_effort: 'medium' (snake_case) to AWS Bedrock for OpenAI and possibly other non-Anthropic models.

Actual Behavior

The SDK sends reasoningConfig: { maxReasoningEffort: 'medium' } (camelCase nested object), which AWS Bedrock rejects.

Current Status

  • Anthropic models work correctly - they use thinking.budget_tokens
  • OpenAI and possibly other non-Anthropic models fail - they incorrectly use reasoningConfig

Workaround

Use additionalModelRequestFields to bypass the SDK's reasoning configuration:

const model = bedrock('openai.gpt-oss-120b-1:0', {
  additionalModelRequestFields: {
    reasoning_effort: 'medium'  // Send snake_case directly
  }
});

Suggested Fix

For OpenAI and possibly other non-Anthropic models, the SDK should send the raw reasoning_effort value directly with snake_case naming:

if (maxReasoningEffort != null && !isAnthropicModel) {
  return {
    ...bedrockOptions.additionalModelRequestFields,
    reasoning_effort: maxReasoningEffort  // Fix: Use snake_case parameter name
  };
}

AI SDK Version

  • @ai-sdk/amazon-bedrock: 3.0.72 (latest as of 2024-12-30)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelbugSomething isn't working as documentedprovider/amazon-bedrockIssues related to the @ai-sdk/amazon-bedrock provider

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions