Claude API proxy: call Anthropic through the OpenAI SDK or the native Anthropic SDK
Route Claude calls through an LLM gateway two ways: the OpenAI SDK (change the model name to claude-*) or the native Anthropic SDK passthrough. Per-feature cost tracking, prompt-cache-aware costing and budgets enforced before the call.
Claude reaches Cognocient AI two ways. Both use the same proxy key, the same budgets and the same attribution headers, and both show up in the same dashboard.
| OpenAI SDK route | Native Anthropic SDK route | |
|---|---|---|
| Base URL | https://api.cognocient.com/v1 | https://api.cognocient.com (no /v1) |
| Request format | OpenAI Chat Completions, translated for you | Anthropic Messages API, passed through unchanged |
| Best for | One client for every provider; switching models by name | Anthropic-only features, betas, Claude Code |
| Budgets, Emergency Freeze, attribution, cost tracking | ✅ | ✅ |
| Prompt guardrails, response caching, routing rules, failover | ✅ | ❌ |
Setup
Add your Anthropic API key in Settings → AI Providers, then pick a route.
The SDKs also read ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from the environment, which is how Claude Code is pointed at the gateway.
The OpenAI SDK route: what is translated
Any model name starting with claude- is sent to Anthropic. The gateway converts the request to the Messages API and the reply back to the OpenAI shape:
| OpenAI field | Becomes |
|---|---|
system messages | The system prompt |
max_tokens or max_completion_tokens | max_tokens (4,096 if neither is set) |
temperature, top_p | Same |
stop (string or list) | stop_sequences |
tools | Anthropic tool definitions, on streamed and non-streamed calls |
tool_choice: auto / required / none / {"function": {"name"}} | auto / any / none / tool |
parallel_tool_calls: false | disable_parallel_tool_use |
role: "tool" messages | tool_result blocks |
image_url content parts | Image blocks (https URLs and base64 data: URLs) |
| Streaming | Anthropic SSE converted to OpenAI chunks, tool calls included, with a final usage chunk |
response_format (JSON mode) is not translated. For structured output from Claude on this route, use a forced tool call (tool_choice with a function name), which is what LangChain's with_structured_output does.
The native route: passthrough
On https://api.cognocient.com/v1/messages your request body and anthropic-* headers reach Anthropic unchanged, so new models, beta headers, extended thinking, PDFs and prompt-caching controls work the day Anthropic ships them. Budgets, the Emergency Freeze, attribution headers and cost tracking apply. Prompt guardrails, response caching, routing rules and provider failover don't, because they need to read or rewrite the request in OpenAI form.
Prompt caching and cost
Anthropic reports cache reads and cache writes separately, and they are priced differently: reads well below the input rate, writes above it (with a higher rate for 1-hour writes). Cognocient AI prices each part at its own rate, so a call that hits the cache shows its real cost, and Context Tax (Growth plan) can tell you which features would benefit from caching their system prompt.
Claude on AWS Bedrock
Claude models hosted on Bedrock use Bedrock model IDs (anthropic.claude-..., or us. / eu. / global. inference profiles) and your AWS credentials. See AWS Bedrock.
Frequently asked questions
Related articles
Supported Providers
OpenAI, Anthropic, Gemini, Mistral, Groq, Together, Azure, AWS Bedrock, Vertex AI, and custom OpenAI-compatible endpoints.
OpenAI
OpenAI SDK through the gateway: chat, Responses, embeddings, images, audio and batches with per-feature cost and budgets.
Google Gemini
Gemini models with the OpenAI SDK, embeddings and Imagen, with per-feature cost and budgets.