Try Bifrost Enterprise free for 14 days.
Request access

[ Provider Guide ]

Anthropic Provider on Bifrost

Anthropic has significant structural differences from OpenAI's format. Bifrost performs extensive conversion, including system message extraction, tool message grouping, thinking block transformation, parameter renaming, and content format conversion, so OpenAI-style clients can route Claude models through the gateway.

Anthropic provider summary

Bifrost supports Anthropic models through OpenAI-compatible APIs and Anthropic-compatible passthrough routes.

Common Anthropic model IDs used in Bifrost routes:

  • claude-opus-4-6 (claude-opus-4-6-20260205)
  • claude-sonnet-4-5 (claude-sonnet-4-5-20250929)
  • claude-opus-4-5 (claude-opus-4-5-20251101)
  • claude-3-7-sonnet (claude-3-7-sonnet-20250219)
  • claude-3-haiku (claude-3-haiku-20240307)
PropertyDetails
DescriptionClaude is Anthropic's model family for reasoning, coding, and language tasks.
Provider route on Bifrostanthropic/<model>
Provider docAnthropic
API endpoint for providerhttps://api.anthropic.com
Supported endpoints/v1/chat/completions, /v1/responses, /v1/complete, /v1/files, /v1/messages/batches, /v1/models, /anthropic/v1/messages (passthrough)

Supported OpenAI parameters

Quick list of OpenAI-style parameters accepted while targeting Anthropic through Bifrost.

[
  "stream",
  "stop",
  "temperature",
  "top_p",
  "max_tokens",
  "max_completion_tokens",
  "tools",
  "tool_choice",
  "response_format",
  "user",
  "reasoning",
  "top_k"
]

Use as a Claude Code backend

Claude Code can use Bifrost as an Anthropic-compatible backend by pointing ANTHROPIC_BASE_URL to Bifrost's Anthropic endpoint. This is a common setup for routing Claude traffic through governance, logs, and fallback.

# Point Claude Code to Bifrost's Anthropic-compatible endpoint
export ANTHROPIC_BASE_URL="http://localhost:8080/anthropic"

# Use your Bifrost virtual key (or provider key depending on setup)
export ANTHROPIC_API_KEY="vk_your_key"

# Launch Claude Code
claude

For full walkthrough and troubleshooting, see Claude Code gateway setup.

Supported operations

Anthropic has different payload structures than OpenAI. Bifrost translates requests and responses so your existing OpenAI-style clients can still work. Embeddings, Speech, Transcriptions, and Image Generation are not supported by the upstream Anthropic API. These return UnsupportedOperationError.

OperationNon-streamingStreamingUpstream endpoint
Chat CompletionsYesYes/v1/messages
Responses APIYesYes/v1/messages
Text CompletionsYesNo/v1/complete
EmbeddingsNoNo-
Speech (TTS)NoNo-
Transcriptions (STT)NoNo-
Image GenerationNoNo-
FilesYes-/v1/files
BatchYes-/v1/messages/batches
List ModelsYes-/v1/models

Beta headers

Bifrost automatically manages Anthropic beta headers by detecting required headers from request features and injecting them. Headers are validated per provider to prevent unsupported headers from reaching the upstream API. Passthrough headers are forwarded when set manually via the anthropic-beta request header.

Beta headerAnthropicAzureVertexBedrockAuto-injected
computer-use-2025-01-24 / computer-use-2025-11-24YesYesYesYesYes (tool type detection)
structured-outputs-2025-11-13YesYesNoYesYes (strict/output_format)
advanced-tool-use-2025-11-20YesYesNoNoYes (defer_loading/input_examples/allowed_callers)
mcp-client-2025-11-20YesYesNoNoYes (mcp_servers detection)
prompt-caching-scope-2026-01-05YesYesNoNoYes (cache_control.scope)
compact-2026-01-12YesYesYesYesYes (compaction edit)
context-management-2025-06-27YesYesYesYesYes (clear edits)
files-api-2025-04-14YesYesNoNoYes (files endpoint)
interleaved-thinking-2025-05-14YesYesYesYesYes (thinking enabled/adaptive)
skills-2025-10-02YesYesNoNoPassthrough
context-1m-2025-08-07YesYesYesYesPassthrough
fast-mode-2026-02-01YesNoNoNoYes (speed=fast)
redact-thinking-2026-02-12YesYesNoNoPassthrough

API reference by operation

Gateway paths and upstream Anthropic endpoints, aligned with the Bifrost Anthropic provider docs.

1) Chat Completions

Primary request path. Maps to upstream /v1/messages. Use extra_params or pass Anthropic-specific fields (for example top_k) directly in the request body.

curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-3-5-sonnet",
    "messages": [{"role": "user", "content": "Hello"}],
    "top_k": 40
  }'

2) Responses API

Uses the same underlying /v1/messages endpoint. Converts between OpenAI's Responses format and Anthropic's Messages format. Supports function, computer_use_preview, web_search, and mcp tool types.

curl -X POST http://localhost:8080/v1/responses \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-3-5-sonnet",
    "input": "Hello, how are you?",
    "top_k": 40
  }'

3) Text Completions (legacy)

Legacy API using upstream /v1/complete. Streaming is not supported. The prompt is auto-wrapped with \n\nHuman: {prompt}\n\nAssistant:; max_tokens maps to max_tokens_to_sample.

4) Batch API

Request formats: requests array (CustomID + Params) or input_file_id. Cursor-based pagination with after_id, before_id, limit. Response is JSONL with {custom_id, result: {type, message}}.

Upstream endpoints:

  • POST /v1/messages/batches: Create
  • GET /v1/messages/batches: List
  • GET /v1/messages/batches/{batch_id}: Retrieve
  • POST /v1/messages/batches/{batch_id}/cancel: Cancel

5) Files API

Requires beta header anthropic-beta: files-api-2025-04-14 (auto-injected by Bifrost on files endpoints). Upload uses multipart/form-data with file (required) and filename (optional). Field mapping: size_bytesbytes, mime_typecontent_type. File purpose is always "batch"; status is always "processed".

curl -X POST http://localhost:8080/v1/files \
  -F "file=@document.pdf"

Gateway endpoints:

  • POST /v1/files
  • GET /v1/files (cursor pagination)
  • GET /v1/files/{file_id}
  • DELETE /v1/files/{file_id}
  • GET /v1/files/{file_id}/content

6) List Models

GET /v1/models?limit={defaultPageSize} with no body. Field mapping: id (prefixed anthropic/), display_namename, created_at (Unix timestamp). Token-based pagination with NextPageToken, FirstID, LastID. Multi-key setups aggregate results and filter by allowed_models when configured.

curl http://localhost:8080/v1/models

Prompt caching (Anthropic)

Add cache directives to system messages, user messages, and tool definitions. Bifrost also forwards a top-level cache_control object on /anthropic/v1/messages requests unchanged.

Where to apply cache_controlValueUse case
System content blocks{ "type": "ephemeral" }Large static instructions and policies
User message content blocks{ "type": "ephemeral" }Repeated context blobs (docs/logs/code)
Tool definitions{ "type": "ephemeral" }Stable tool schemas reused across requests

Caching example

curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-3-5-sonnet",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "This is cached context",
            "cache_control": {"type": "ephemeral"}
          }
        ]
      }
    ],
    "system": [
      {
        "type": "text",
        "text": "You are a helpful assistant",
        "cache_control": {"type": "ephemeral"}
      }
    ]
  }'

Reasoning / thinking

reasoning.effort maps to thinking.type (always "enabled"). reasoning.max_tokens maps to thinking.budget_tokens. Minimum budget is 1024 tokens; -1 is converted to 1024 automatically.

// Request
{"reasoning": {"effort": "high", "max_tokens": 2048}}

// Anthropic conversion
{"thinking": {"type": "enabled", "budget_tokens": 2048}}

Dropped parameters

The following OpenAI-style parameters are silently ignored when targeting Anthropic through Bifrost:

[
  "frequency_penalty",
  "presence_penalty",
  "logit_bias",
  "logprobs",
  "top_logprobs",
  "seed",
  "parallel_tool_calls",
  "service_tier"
]

Supported Claude models

Use the provider prefix anthropic/ in Bifrost model routes for deterministic provider targeting.

FamilyModel IDBifrost routeTypical usage
Claude Opus 4.6claude-opus-4-6-20260205anthropic/claude-opus-4-6-20260205Reasoning-heavy tasks
Claude Sonnet 4.5claude-sonnet-4-5-20250929anthropic/claude-sonnet-4-5-20250929General production default
Claude Opus 4.5claude-opus-4-5-20251101anthropic/claude-opus-4-5-20251101High-depth analysis
Claude Opus 4.1claude-opus-4-1-20250805anthropic/claude-opus-4-1-20250805High-quality legacy ops
Claude 3.7 Sonnetclaude-3-7-sonnet-20250219anthropic/claude-3-7-sonnet-20250219Thinking-enabled workflows
Claude 3.5 Sonnetclaude-3-5-sonnet-20240620anthropic/claude-3-5-sonnet-20240620Stable broad compatibility
Claude 3 Haikuclaude-3-haiku-20240307anthropic/claude-3-haiku-20240307Fast + lower-cost responses

Core request mapping

Bifrost normalizes OpenAI-format input to Anthropic-format fields. This is the key layer that enables compatibility without changing client code.

OpenAI-style paramAnthropic conversionNotes
max_completion_tokensmax_tokensRenamed for Anthropic Messages API
temperature, top_pDirect pass-through
stopstop_sequencesSupports array values
response_formatoutput_formatStructured outputs conversion
toolsname + input_schemafunction.name → name; function.parameters → input_schema; strict dropped
tool_choiceType mapped"auto" → auto | "none" → none | "required" → any | specific tool → {"type":"tool","name":"X"}
reasoningthinkingreasoning.effort → thinking.type (enabled); max_tokens → budget_tokens (min 1024)
usermetadata.user_idUser identifier wrapped in metadata
top_kVia extra_paramsAnthropic-specific; pass in body or extra_params

Implementation caveats

CaveatImpactSeverity
System message extractionSystem messages removed from array, placed in separate system fieldHigh
Tool message groupingConsecutive tool messages merged into single user messageHigh
Minimum reasoning budgetreasoning.max_tokens must be >= 1024 or request failsHigh
Dynamic budget conversionreasoning.max_tokens = -1 converted to 1024Medium
Strict tool mode droppedstrict: true in tool definitions silently droppedMedium
Arguments serializationTool call input (object) serialized to arguments (JSON string)Low

Response conversion

Key field mappings on the way back to OpenAI-compatible responses:

  • stop_reasonfinish_reason (end_turn/stop_sequencestop, max_tokenslength, tool_usetool_calls)
  • Cache token counts roll into prompt_tokens with breakdown in prompt_tokens_details
  • thinking blocks → reasoning_details
  • Streaming: message_startcontent_block_deltamessage_stop

Anthropic passthrough

Send native Anthropic Messages API payloads to /anthropic/v1/messages when you need full control over Anthropic request shapes.

curl -X POST http://localhost:8080/anthropic/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-bf-vk: vk_your_key" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "What changed between versions?"}]
  }'

Authoritative references

[ BIFROST FEATURES ]

Open Source & Enterprise

Everything you need to run AI in production, from free open source to enterprise-grade features.

01 Governance

SAML support for SSO and Role-based access control and policy enforcement for team collaboration.

02 Adaptive Load Balancing

Automatically optimizes traffic distribution across provider keys and models based on real-time performance metrics.

03 Cluster Mode

High availability deployment with automatic failover and load balancing. Peer-to-peer clustering where every instance is equal.

04 Alerts

Real-time notifications for budget limits, failures, and performance issues on Email, Slack, PagerDuty, Teams, Webhook and more.

05 Log Exports

Export and analyze request logs, traces, and telemetry data from Bifrost with enterprise-grade data export capabilities for compliance, monitoring, and analytics.

06 Audit Logs

Comprehensive logging and audit trails for compliance and debugging.

07 Vault Support

Secure API key management with HashiCorp Vault, AWS Secrets Manager, Google Secret Manager, and Azure Key Vault integration.

08 VPC Deployment

Deploy Bifrost within your private cloud infrastructure with VPC isolation, custom networking, and enhanced security controls.

09 Guardrails

Automatically detect and block unsafe model outputs with real-time policy enforcement and content moderation across all agents.

[ SHIP RELIABLE AI ]

Try Bifrost Enterprise with a 14-day Free Trial

[quick setup]

Drop-in replacement for any AI SDK

Change just one line of code. Works with OpenAI, Anthropic, Vercel AI SDK, LangChain, and more.

1import os
2from anthropic import Anthropic
3
4anthropic = Anthropic(
5 api_key=os.environ.get("ANTHROPIC_API_KEY"),
6 base_url="https://<bifrost_url>/anthropic",
7)
8
9message = anthropic.messages.create(
10 model="claude-3-5-sonnet-20241022",
11 max_tokens=1024,
12 messages=[
13 {"role": "user", "content": "Hello, Claude"}
14 ]
15)
Drop in once, run everywhere.