ReqLLM.Providers.Anthropic.AdapterHelpers (ReqLLM v1.0.0)

View Source

Shared helper functions for Anthropic model adapters (Bedrock, Vertex).

These functions are NOT used by the native Anthropic provider - they are specific to adapters that wrap Anthropic's API in other platforms.

Summary

Functions

Extract structured output from tool calls in response.

Conditionally add a parameter to a map if the value is not nil.

Add extended thinking configuration to request body if enabled.

Prepare context and options for :object operations using structured output.

Functions

extract_and_set_object(response)

Extract structured output from tool calls in response.

Used for :object operations to get the final structured output.

maybe_add_param(body, key, value)

Conditionally add a parameter to a map if the value is not nil.

maybe_add_thinking(body, opts)

Add extended thinking configuration to request body if enabled.

Extended thinking doesn't work when tool_choice forces a specific tool. See: https://docs.claude.com/en/docs/build-with-claude/extended-thinking

prepare_structured_output_context(context, opts)

Prepare context and options for :object operations using structured output.

Creates a synthetic "structured_output" tool and forces tool choice to use it. This leverages Claude's tool-calling for structured JSON output.