Skip to content

feat: Add native structured outputs support for Bedrock Converse API #883

Description

@ndgigliotti

Summary

Amazon Bedrock now supports native structured outputs — the ability to constrain model responses to a defined JSON schema at the API level. This is available across four APIs: Converse, ConverseStream, InvokeModel, and InvokeModelWithResponseStream.

Currently, ChatBedrockConverse.with_structured_output() achieves structured output exclusively through forced tool calling — wrapping the schema as a tool, forcing the model to call it, and parsing the output. The new native API feature offers guaranteed schema compliance without this workaround.

What Bedrock now supports

Two complementary mechanisms:

1. JSON Schema output format

A new outputConfig.textFormat parameter on the Converse/ConverseStream APIs (and analogous parameters on InvokeModel/InvokeModelWithResponseStream):

{
  "outputConfig": {
    "textFormat": {
      "type": "json_schema",
      "structure": {
        "jsonSchema": {
          "schema": "{...}",
          "name": "data_extraction",
          "description": "..."
        }
      }
    }
  }
}

2. Strict tool use

A new strict: true flag on tool definitions that enforces schema compliance on tool call inputs:

{
  "toolSpec": {
    "name": "get_weather",
    "strict": true,
    "inputSchema": { "json": { ... } }
  }
}

Both mechanisms are documented in the Bedrock API reference and user guide.

Supported models

Native structured outputs is only available for select models:

  • Anthropic: Claude Haiku 4.5, Claude Sonnet 4.5, Claude Opus 4.5, Claude Opus 4.6
  • Open-weight: Select Qwen, DeepSeek, Mistral, Google Gemma, NVIDIA Nemotron, MiniMax, Moonshot, and OpenAI models

Notably not supported: Claude 3.x models, Llama, Titan, Cohere, AI21, etc. See the Bedrock docs for the full list.

Current gaps in langchain-aws

Feature Bedrock API langchain-aws
outputConfig.textFormat (JSON schema) Available Not implemented
strict: true on tool definitions Available Not implemented
with_structured_output via forced tool calling N/A (workaround) Implemented

Proposed changes

  1. Add outputConfig support to ChatBedrockConverse — new constructor parameter and inclusion in _converse_params().
  2. Add strict flag support in tool formatting — pass through strict: true in _format_tools() / bind_tools() when specified.
  3. Update with_structured_output() — prefer native outputConfig for supported models, fall back to forced tool calling for others. Design decision: whether to gate by a hardcoded model list or let the Bedrock API surface errors for unsupported models.
  4. Tests — add unit and integration tests for both mechanisms, extending the existing structured output test suite.

Related issues

Implementing native structured outputs would address or help resolve all three.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions