Unified LLM API Explained and How One Client Calls Any Model
A unified LLM API sends one OpenAI-shaped request to any model. See where tool calls, streaming and JSON output break, and how translation and fallback work.
Table of Contents
Your app runs on the OpenAI Python SDK, and a teammate wants Claude for a feature. You point the base URL at Anthropic’s compatibility layer and swap the model. The extraction call fails with a 400, since it asks for JSON object mode and that layer takes only a strict JSON schema. The tool call passes, its strict flag ignored.
A unified LLM API is the layer between one request shape and many providers. The shared OpenAI shape covers most of a request, so plain chat moves with a URL change. The rest differs field by field, starting with tool arguments and stream events.
You will see what a unified LLM API standardizes, where the shape breaks between OpenAI, Anthropic and Gemini, what translation does to a real payload and how fallback fires. The demo runs offline, so you can read every translated field before paying for a request.
TL;DR
- A unified LLM API lets one client send one OpenAI-shaped request and reach models from many providers.
- You can unify in your code with a client SDK, or behind a gateway endpoint that every service calls.
- A
base_urlswap covers plain chat; tool calls, streaming, JSON schema output, reasoning settings, usage fields and errors still differ by provider. - A translation layer rebuilds each request in the provider’s native shape and maps the reply, stop reason and error back.
- Fallback works because errors are normalized first, so a provider outage becomes a status code the router acts on.
What a Unified LLM API Is and the Request Shape It Standardizes
A unified LLM API gives your code one endpoint and one request format, and the layer behind it reaches each provider. Most layers use the OpenAI chat completions shape: a model name, a messages array with roles, optional tools and a response_format. Your code builds that request once.
The shape spread because many vendors publish a base URL that accepts it. The OpenAI SDK reaches them once you change that URL, the API key and the model name. Those layers come close to the OpenAI shape. Several vendors also document fields their layer drops or rejects, and the table below sums up what each vendor page says.
The OpenAI Chat Completions Shape Most Providers Copy
The weather request in this post holds a model, a system turn and a user turn. It also carries one function tool named get_weather with a JSON Schema as its parameters, and tool choice set to auto. Later turns add the assistant and tool roles.
The OpenAI chat completions reference defines each field. Structured output asks for a JSON schema with a strict flag that defaults to false, or the older JSON object mode. Output limits go in max_completion_tokens, and tool calls return their arguments as a JSON string.
Providers That Publish an OpenAI-Shaped Base URL
Two common starting points are Anthropic’s OpenAI SDK compatibility layer and Gemini’s OpenAI compatibility page. Four more vendors publish an OpenAI-shaped base URL. Each row follows that vendor’s own page as of 2026-11-12, so check the page again before you rely on a cell.
| Provider | Base URL | What the vendor’s own doc says |
|---|---|---|
| Anthropic | https://api.anthropic.com/v1/ | Primarily intended to test and compare model capabilities; JSON output only as a strict schema; tool strict flag and reasoning effort ignored; usage detail objects always empty |
| Google Gemini | https://generativelanguage.googleapis.com/v1beta/openai/ | OpenAI library support still in beta; Gemini-only features go in extra_body |
| Groq | https://api.groq.com/openai/v1 | Log probabilities, logit bias, message names or n other than 1 return a 400 |
| DeepSeek | https://api.deepseek.com | Also serves an Anthropic-format base URL at https://api.deepseek.com/anthropic |
| Ollama | http://localhost:11434/v1/ | Local models |
| Together AI | https://api.together.ai/v1 | Base URL for the OpenAI client |
For pricing, see our guide comparing LLM API providers on price and context window.
Two Ways to Unify, a Client SDK or a Gateway Endpoint
You can unify model access in two places. A client SDK translates inside your process, so one library call reaches each provider with no extra hop. A gateway endpoint translates on a server, so every service and language sends the same HTTP request and shares one set of keys and fallbacks.
The Unified LLM SDK Route
A unified LLM SDK is a library in your app. You call one function, and the library builds the provider’s native request, sends it with that provider’s key and maps the reply back. Mozilla.ai’s any-llm works this way, with no proxy or gateway server required.
The cost shows up as services multiply. Every service holds its own provider keys, fallback logic lives in application code, and a translation fix ships only when every app upgrades and redeploys. With one codebase in one language, or a prototype, you will rarely feel it.
The Unified LLM API Gateway Route
A unified LLM API gateway moves translation onto a server. Every service, in any language, sends the same OpenAI-shaped HTTP request to one URL, and provider keys stay on that server. If the term is new to you, start with what an AI gateway is.

You get one key store, one fallback config and one place to rename a model for every caller. Auth and rate limits sit in the same hop. Read the layers inside an AI gateway for each one; this post stays on translation and fallback.
The choice comes down to how many callers you have. One service in one language can start with an SDK. Several services, several languages, or keys kept out of application code point to a gateway. Both routes take the same OpenAI-style messages list your code already builds.
Where Compatibility Breaks Across Providers
Compatibility breaks in the same few places. Tools are defined and returned differently, streams chunk and end differently, and JSON schema output, reasoning, the system prompt, token usage and errors each sit in their own fields. Plain chat survives a base URL swap, and these fields need translation.
| Field | OpenAI chat completions | Anthropic Messages | Gemini generateContent |
|---|---|---|---|
| Tool definition | function.parameters with strict | input_schema with strict | functionDeclarations |
| Tool call in the reply | arguments as a JSON string | tool_use block, input object | functionCall part, args object |
| Stop signal | finish_reason stop, length, tool_calls, content_filter | stop_reason end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal, model_context_window_exceeded | finishReason STOP, MAX_TOKENS, SAFETY and others, no tool-call value |
| Streaming | delta chunks, data: [DONE], optional usage chunk | Named SSE events, input_json_delta for tool input | Separate streamGenerateContent method |
| Structured output | json_schema (strict defaults to false) or json_object | output_config.format | responseMimeType plus responseJsonSchema |
| Reasoning | reasoning_effort none to max, default medium | output_config.effort low to max; thinking adaptive, or budget_tokens of at least 1,024 where accepted | thinkingBudget or thinkingLevel |
| System prompt | system or developer message | Top-level system | systemInstruction |
| Token usage | prompt_tokens, completion_tokens, reasoning_tokens | input_tokens, output_tokens | promptTokenCount, candidatesTokenCount, thoughtsTokenCount |
| Overload and rate limit | 503 server_is_overloaded, 429 | 529 overloaded_error, 429; errors can arrive inside a 200 stream | 503 UNAVAILABLE, 429 RESOURCE_EXHAUSTED |
Tool Calls and Finish Reasons
Three rows of the table cause the most trouble when code parses replies. Tool arguments arrive as a string from OpenAI and as an object from the other two, which breaks parsing code. A loop waiting for tool_calls never sees tool_use. Overload errors carry different statuses, which decides whether a fallback fires.
Anthropic’s stop reasons add refusal, pause_turn and a context window value that OpenAI’s finish_reason lacks. Gemini has no tool-call finish reason. A translator sets tool_calls by finding functionCall parts. The tool values in the Gemini generateContent reference, MALFORMED_FUNCTION_CALL, UNEXPECTED_TOOL_CALL and TOO_MANY_TOOL_CALLS, mark failures.
Streaming Chunks and Token Usage
OpenAI ends a stream with a done marker and sends usage only when you ask for it. Anthropic sends named events such as message_start, with tool arguments arriving as JSON fragments. Gemini streams from a separate method. A cost dashboard needs one mapping per provider because token counts carry different names at each vendor.
Structured Output and Reasoning Parameters
JSON output sits in a different field at each vendor, and so does reasoning. OpenAI takes an effort from none to max. Anthropic pairs an effort from low to max with adaptive thinking, or a budget of at least 1,024 tokens on models that accept it. Gemini has its own thinking config.
How a Unified LLM API Translates One Request Field by Field
A translator reads the OpenAI-shaped request, moves each field to where the target provider expects it, then maps the reply back. For Anthropic, the system message moves to a top-level field and parameters becomes input_schema. The translator also sets max_tokens and turns tool_use blocks back into tool_calls.
The complete translate_demo.py is a small stand-in, not gateway code. This newly supplied harness uses synthetic fixtures matching the illustrative payloads below, not captured model replies or the author’s original test harness. It was tested offline with Python 3.11, openai 3.49.0, anthropic 2.8.0 and httpx2 2.16.0.
Download the file, then run:
python3.11 -m venv .venv
.venv/bin/python -m pip install openai==3.49.0 anthropic==2.8.0 httpx2==2.16.0
.venv/bin/python translate_demo.py
The script runs assertions before printing outputs 1–5. It includes request and response translation, copies function.strict when present, and stores the complete native assistant content before mapping the reply. Tests cover strict true, false and absent, plus unchanged thinking and redacted-thinking blocks on a tool follow-up. Both SDKs use mock transports; no API key or paid call is needed.
This is a single-conversation, non-streaming demo for the text, tool and strict JSON-schema cases shown here, not a general adapter. Its signature and token counts are synthetic; it tests field preservation, not live provider acceptance or schema enforcement. A gateway needs isolated conversation storage rather than this process-local dictionary.
The Tool Call Round Trip
The request follows the Anthropic tool use guide. In output 1b the system message moves to its own field and parameters becomes input_schema. Max tokens lands at 4096, the demo’s own default, because Anthropic requires the field and the client sent none.
--- 1a OpenAI-shape request from the client
{
"model": "claude-sonnet-5-5",
"messages": [
{
"role": "system",
"content": "You answer weather questions."
},
{
"role": "user",
"content": "What's the weather like in San Francisco right now, and what time is it there?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either 'celsius' or 'fahrenheit'"
}
},
"required": [
"location"
]
}
}
}
],
"tool_choice": "auto"
}
--- 1b same request in Anthropic Messages shape
{
"model": "claude-sonnet-5-5",
"messages": [
{
"role": "user",
"content": "What's the weather like in San Francisco right now, and what time is it there?"
}
],
"max_tokens": 4096,
"system": "You answer weather questions.",
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either 'celsius' or 'fahrenheit'"
}
},
"required": [
"location"
]
}
}
],
"tool_choice": {
"type": "auto"
}
}
The fixture reply holds a thinking block, a text block and a tool use block. Output 1d maps it back: tool_calls as the finish reason, arguments as a JSON string, usage of 100, 50 and 150. On Claude 5 models Anthropic wants that thinking block back unchanged with the tool result.
--- 1c Anthropic response fixture
{
"id": "msg_01234",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5-5",
"content": [
{
"type": "thinking",
"thinking": "",
"signature": "EosnCkYICxIMMb3LzNrMu..."
},
{
"type": "text",
"text": "I'll help you check the current weather and time in San Francisco."
},
{
"type": "tool_use",
"id": "toolu_01A09q90qw90lq917835lq9",
"name": "get_weather",
"input": {
"location": "San Francisco, CA"
}
}
],
"stop_reason": "tool_use",
"stop_sequence": null,
"stop_details": null,
"usage": {
"input_tokens": 100,
"output_tokens": 50
}
}
--- 1d normalised to OpenAI chat completion shape
{
"id": "msg_01234",
"object": "chat.completion",
"created": 0,
"model": "claude-sonnet-5-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I'll help you check the current weather and time in San Francisco.",
"tool_calls": [
{
"id": "toolu_01A09q90qw90lq917835lq9",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"San Francisco, CA\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 100,
"completion_tokens": 50,
"total_tokens": 150
}
}
The OpenAI message has no field for a thinking block. The translator stores the original content by tool call id instead. Next turn, the tool message becomes a tool result block in a user message and the stored assistant turn goes back as is. Output 2b keeps all three blocks; output 2c, rebuilt from tool calls, loses one.
--- 2 follow-up request in Anthropic Messages shape (tool_use and tool_result blocks)
{
"model": "claude-sonnet-5-5",
"messages": [
{
"role": "user",
"content": "What's the weather like in San Francisco right now, and what time is it there?"
},
{
"role": "assistant",
"content": [
{
"type": "thinking",
"thinking": "",
"signature": "EosnCkYICxIMMb3LzNrMu..."
},
{
"type": "text",
"text": "I'll help you check the current weather and time in San Francisco."
},
{
"type": "tool_use",
"id": "toolu_01A09q90qw90lq917835lq9",
"name": "get_weather",
"input": {
"location": "San Francisco, CA"
}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01A09q90qw90lq917835lq9",
"content": "SYNTHETIC tool output: 15 degrees celsius, sunny"
}
]
}
],
"max_tokens": 4096,
"system": "You answer weather questions.",
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either 'celsius' or 'fahrenheit'"
}
},
"required": [
"location"
]
}
}
],
"tool_choice": {
"type": "auto"
}
}
2b assistant turn sent back unchanged, block types: ['thinking', 'text', 'tool_use']
2c rebuilt from tool_calls alone, block types: ['text', 'tool_use'] (thinking block lost)
JSON Schema Output on a Model With a Different Field
The contact-extraction request comes from Anthropic structured outputs. In output 3b the schema moves into output_config.format, and the JSON reply returns as plain message content. A translator can map reasoning effort to Anthropic’s effort setting the same way for low to max; none and minimal have no Anthropic twin.
--- 3a OpenAI-shape request with response_format json_schema
{
"model": "claude-sonnet-5-5",
"messages": [
{
"role": "user",
"content": "Extract the key information from this email: John Smith (john@example.com) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "contact",
"strict": true,
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"plan_interest": {
"type": "string"
},
"demo_requested": {
"type": "boolean"
}
},
"required": [
"name",
"email",
"plan_interest",
"demo_requested"
],
"additionalProperties": false
}
}
}
}
--- 3b same request in Anthropic Messages shape (output_config.format)
{
"model": "claude-sonnet-5-5",
"messages": [
{
"role": "user",
"content": "Extract the key information from this email: John Smith (john@example.com) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
}
],
"max_tokens": 4096,
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"plan_interest": {
"type": "string"
},
"demo_requested": {
"type": "boolean"
}
},
"required": [
"name",
"email",
"plan_interest",
"demo_requested"
],
"additionalProperties": false
}
}
}
}
--- 3c normalised to OpenAI chat completion shape
{
"id": "msg_01234",
"object": "chat.completion",
"created": 0,
"model": "claude-sonnet-5-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\n \"name\": \"John Smith\",\n \"email\": \"john@example.com\",\n \"plan_interest\": \"Enterprise\",\n \"demo_requested\": true\n}"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 100,
"completion_tokens": 50,
"total_tokens": 150
}
}
One OpenAI SDK Client Against the Translator
Step 4 points the stock OpenAI SDK at a local stand-in endpoint built on an httpx2 mock transport. Your client code stays the same create call you already ship. Behind it the request turns Anthropic-shaped, and the fixture reply comes back as an OpenAI object with tool_calls as its finish reason.
--- 4 OpenAI SDK against the local stand-in
finish_reason: tool_calls
tool call: get_weather {"location": "San Francisco, CA"}
usage: 100 50 150
Fallback Across Providers With One Translated Request
Fallback works when the layer keeps one canonical request and resends it to the next model after a failure it can recognize. Error mapping makes that possible. Anthropic’s 529 overloaded_error and OpenAI’s 503 server_is_overloaded mean the same thing, and the layer must map both to statuses on its failover list.
In the demo, leg 1 sends the weather request to claude-sonnet-5-5 in Anthropic shape and gets the 529 fixture back. The translator maps it to 502 and finds 502 on its failover list. Leg 2 for gpt-5.6-sol is the client request with only the model changed. The demo prints that fallback payload without calling a second provider.
--- 5a leg 1 Anthropic error fixture (HTTP 529) mapped to a gateway status
{
"status": 502,
"error": {
"message": "The API is temporarily overloaded.",
"type": "overloaded_error"
}
}
5b failover on this status: True
--- 5c leg 2 payload prepared for an OpenAI-format provider (same request, new model, no translation)
{
"model": "gpt-5.6-sol",
"messages": [
{
"role": "system",
"content": "You answer weather questions."
},
{
"role": "user",
"content": "What's the weather like in San Francisco right now, and what time is it there?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
],
"description": "The unit of temperature, either 'celsius' or 'fahrenheit'"
}
},
"required": [
"location"
]
}
}
}
],
"tool_choice": "auto"
}
Why Error Mapping Decides Whether the Hop Fires
Compare Anthropic error types with OpenAI error codes and the overload case already disagrees, 529 against 503. Gemini lists 503 UNAVAILABLE and 429 RESOURCE_EXHAUSTED as the errors worth retrying. Your failover list only ever sees the status after the layer maps it.

The fallback has two branches. When the mapped status is on the list, the layer resends the same request to the next model. When the status is missing, or the error was never mapped, the client gets the error and nothing else runs. One cause of a fallback that never fires is that second branch.
Reversing the Chain
Put an OpenAI model first and Claude second, and the translated leg moves to the end of the chain. Leg 1 goes out as sent, and leg 2 is rebuilt in Anthropic shape with the same field moves shown earlier. Your client reads the same OpenAI response shape whichever model answered.
A resend is not always safe. Anthropic documents that an error can arrive inside a stream after a 200. By then tokens may already be on the user’s screen, and a tool may already have run. For retries, idempotency and chain order, see how to design an LLM fallback strategy.
What a Unified LLM API Cannot Hide
A unified LLM API hides request formats. Two models behind it still differ in context window, price per token, tool-calling habits and refusals. So after a switch, check your prompts, evals and budgets against each model you now call, and confirm the fallback target behaves like the first.
Behaviour, Context and Price Stay per Model
One model calls a tool where another answers in text. Replay real tool prompts on every target. A target can also reject what the first model accepted. OpenAI’s GPT-6 Luna page allows Chat Completions function calling only with reasoning effort set to none, which is why the example falls back to gpt-5.6-sol.
Context limits differ. A fallback target must hold your longest conversation. Per-token prices differ too, so check each target against your budget. On Claude 5 models thinking is on by default and counts toward max_tokens. Set max_completion_tokens yourself to fit thinking plus the answer.
Strict flags do not cross every boundary. Anthropic’s compatibility layer ignores strict on tools, while the native Messages API supports strict tool use, so a translator must carry the flag across or arguments go unchecked. OpenAI’s reference warns that arguments may not be valid JSON. Validate them before a tool runs.
Required tool choice becomes any in the mapping, and Claude Sonnet 5.5 and Opus 5.5 reject any under adaptive thinking, their default. So a correct mapping can still fail. Anthropic’s compatibility layer has no prompt caching and omits thinking text from replies. Gemini-only features go in extra_body, and refusal and pause_turn have no OpenAI finish reason.
Running One Client Through Future AGI Agent Command Center
Future AGI Agent Command Center is an Apache-2.0 gateway that exposes /v1/chat/completions, /v1/messages, /v1/responses and /v1/embeddings for 100+ providers. You point the OpenAI SDK at it by changing the base URL and API key. On /v1/chat/completions it translates each request to the provider’s native format and back.
The Agent Command Center quickstart shows that swap against the hosted URL, https://gateway.futureagi.com/v1. Per provider configuration, OpenAI-format providers pass straight through, and Anthropic, Gemini, Bedrock and Cohere are translated. A provider block sets a base URL and an API format.
For Anthropic models on /v1/chat/completions, the gateway lifts the system message to a top-level field, writes tools with input_schema and puts JSON schema output into output_config.format. It takes max tokens from the client, else 4096. Replies map end_turn to stop and tool_use to tool_calls with usage summed, and streams arrive as OpenAI-format chunks.
Native Anthropic clients call /v1/messages, one of the gateway endpoints. When an Anthropic provider serves the model, the gateway forwards the request body as the client sent it, so thinking blocks arrive unchanged. That makes /v1/messages the route for multi-turn tool loops on Claude 5 models.
The Fallback Config and the Client Call
The worked fallback in gateway-config.yaml lists an anthropic provider for claude-sonnet-5-5 and an openai provider for gpt-5.6-sol. Failover covers 429, 500, 502, 503, 504 and timeouts, and the model fallback chain sends claude-sonnet-5-5 to gpt-5.6-sol. The gateway maps Anthropic’s 529 to 502, so the fallback triggers.
providers:
anthropic:
base_url: "https://api.anthropic.com"
api_key: "${ANTHROPIC_API_KEY}"
api_format: "anthropic"
default_timeout: 120s
headers:
anthropic-version: "2023-06-01" # value copied from config.example.yaml
models:
- claude-sonnet-5-5
openai:
base_url: "https://api.openai.com"
api_key: "${OPENAI_API_KEY}"
api_format: "openai"
default_timeout: 60s
models:
- gpt-5.6-sol
auth:
enabled: true
keys:
- name: "app-key"
key: "sk-agentcc-replace-me"
key_type: "internal" # lets the key use the providers in this file; without it requests fail with 403
owner: "app"
models: ["claude-sonnet-5-5", "gpt-5.6-sol"]
routing:
default_strategy: "round-robin" # the gateway builds its router, and so failover, only when routing sets a strategy or targets, or a model is listed under more than one provider
# model_fallbacks only runs when routing has a default_strategy, failover is enabled and the status is in the list.
# Anthropic 529 overloaded_error is mapped to 502 by the gateway, so 502 must be listed.
failover:
enabled: true
max_attempts: 3
on_status_codes: [429, 500, 502, 503, 504]
on_timeout: true
model_fallbacks:
claude-sonnet-5-5:
- gpt-5.6-sol
The chain is documented under routing and model fallbacks. It fires once routing sets a default strategy (round-robin here) and failover is on, so ship all three. On a standalone gateway the app key needs key_type internal to use these providers, or requests get a 403.
The client points at the self-hosted gateway on localhost port 8080, with the hosted URL as the alternative, and reads the provider, model-used and fallback-used headers from each response. The app key’s models list allows both models. Self-host with Docker Compose or Helm from Future AGI on GitHub.
import os
from openai import OpenAI
# Self-hosted gateway that loads gateway-config.yaml; AGENTCC_API_KEY is the app-key value in that file.
# hosted: https://gateway.futureagi.com/v1 with a Command Center key
client = OpenAI(base_url=os.environ.get("AGENTCC_BASE_URL", "http://localhost:8080/v1"), api_key=os.environ["AGENTCC_API_KEY"])
raw = client.chat.completions.with_raw_response.create(
model="claude-sonnet-5-5",
messages=[
{"role": "system", "content": "You answer weather questions."},
{"role": "user", "content": "What's the weather like in San Francisco right now, and what time is it there?"},
],
tools=[{"type": "function", "function": {
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]},
}}],
)
completion = raw.parse()
print(completion.choices[0].finish_reason)
print(raw.headers.get("x-agentcc-provider"), raw.headers.get("x-agentcc-model-used"), raw.headers.get("x-agentcc-fallback-used"))
From One Failing 400 to One Client That Calls Any Model
Switching the response format to a JSON schema with strict set to true clears the 400 on the Claude extraction call. Send it straight to Anthropic or through a gateway that moves it into output_config.format. Add a fallback to a second provider, and the same OpenAI SDK call reaches either model.
Before your next model switch, walk the break table against your own code, starting with tool arguments and stop reasons. Write down which statuses should trigger a fallback, and check that each provider’s overload error maps onto one of them. An unmapped error goes straight back to the client.
Then run the Agent Command Center quickstart with the extraction request that started all this, and read the response headers to see which model answered. When the fallback-used header is set, the chain ran and your client code stayed exactly as it was.
Frequently Asked Questions
What is a unified LLM API?
How do I call OpenAI, Claude and Gemini from one Python client?
What is the difference between a unified LLM SDK and a unified LLM API gateway?
Is an LLM unified API platform free to use?
What happens to my request when one provider fails behind a unified LLM API?
Follow one LLM request through an AI gateway architecture, from virtual-key auth, guardrails and cache lookup to fallback, provider translation, logs and cost.
Run an AI data residency check on your LLM gateway: list configured destinations, read the provider per request, force a failover and see where logs land.
Inside Future AGI open source in Q2 2026: the platform shipped under Apache 2.0, Error Feed and the Agent Command Center went live, traces hit billions.