# `ReqLLM.Providers.Anthropic`
[🔗](https://github.com/agentjido/req_llm/blob/main/lib/req_llm/providers/anthropic.ex#L1)

Provider implementation for Anthropic Claude models.

Supports Claude 3 models including:
- claude-sonnet-4-5-20250929
- claude-3-5-haiku-20241022
- claude-3-opus-20240229

## Key Differences from OpenAI

- Uses `/v1/messages` endpoint instead of `/chat/completions`
- Uses `x-api-key` authentication by default; gateways can select `auth_scheme: :bearer`
- Different message format with content blocks
- Different response structure with top-level `role` and `content`
- System messages are included in the messages array, not separate
- Tool calls use different format with content blocks

## Usage

    iex> ReqLLM.generate_text("anthropic:claude-sonnet-4-5-20250929", "Hello!")
    {:ok, response}

# `attach`

Default implementation of attach/3.

Sets up Bearer token authentication and standard pipeline steps.

# `attach_stream`

Default implementation of attach_stream/4.

Builds complete streaming requests using OpenAI-compatible format.

# `base_url`

# `build_body`

Default implementation of build_body/1.

Builds request body using OpenAI-compatible format for chat and embedding operations.

# `decode_response`

Default implementation of decode_response/1.

Handles success/error responses with standard ReqLLM.Response creation.

# `decode_stream_event`

Default implementation of decode_stream_event/2.

Decodes SSE events using OpenAI-compatible format.

# `default_base_url`

# `default_env_key`

# `encode_body`

Default implementation of encode_body/1.

Encodes request body using OpenAI-compatible format for chat and embedding operations.

# `extract_usage`

Default implementation of extract_usage/2.

Extracts usage data from standard `usage` field in response body.

# `map_reasoning_effort_to_budget`

Maps reasoning effort levels to token budgets.

This is the canonical source of truth for Anthropic reasoning effort mappings,
used by all providers hosting Anthropic models.

- `:minimal` → 512 tokens
- `:low` → 1,024 tokens
- `:medium` → 2,048 tokens
- `:high` → 4,096 tokens
- `:xhigh` and `:max` → 8,192 tokens for legacy fixed-budget models

## Examples

    iex> ReqLLM.Providers.Anthropic.map_reasoning_effort_to_budget(:low)
    1024

    iex> ReqLLM.Providers.Anthropic.map_reasoning_effort_to_budget("medium")
    2048

# `prepare_request`

Default implementation of prepare_request/4.

Handles :chat, :object, and :embedding operations using OpenAI-compatible patterns.

# `provider_extended_generation_schema`

# `provider_id`

# `provider_schema`

# `supported_provider_options`

# `tool_to_anthropic_format`

Convert a ReqLLM.Tool to Anthropic's tool format.

This is made public so that Bedrock and Vertex formatters can reuse it.

# `translate_options`

Default implementation of translate_options/3.

Pass-through implementation that returns options unchanged.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
