LLM providers
OpenAI and Anthropic ride on typed wire-format surfaces. Change one URL, keep your SDK. Streaming, tool calls, and JSON shape all survive the round trip. No changes to retries, auth, or response parsing.
OpenAI
The OpenAI surface mounts under /v1/<route>/ and speaks the full Chat Completions and Responses APIs.
from openai import OpenAI
client = OpenAI(
api_key="sk-...",
base_url="https://adaptiveapi.example.com/v1/rt_yourtenant_xxxxx",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user",
"content": "Was ist eine Hashmap?"}],
extra_headers={"X-AdaptiveApi-Target-Lang": "de"},
stream=True,
)
for chunk in resp:
print(chunk.choices[0].delta.content or "", end="")
What is supported
- Chat Completions. Messages, system prompts, multi-turn, streaming.
- Responses API. Same wire format, same translation rules.
- Tool calls.
tool_calls[*].function.argumentsis JSON-in-JSON. The pipeline parses the inner JSON, walks it with a key-aware denylist, translates the human-text leaves, and re-serialises.tool_call_id,function.name, and argument keys are preserved verbatim. - Streaming. Sentence-boundary buffering by default, progressive available per request. See Translation pipeline.
- Vision and audio. Image and audio parts pass through. Only text parts are translated.
What you change
One thing. The base URL.
Everything else (your retries, your timeouts, your error handling, your streaming consumer) stays untouched.
Anthropic
The Anthropic surface mounts under /anthropic/v1/<route>/ and speaks the Messages API.
import anthropic
client = anthropic.Anthropic(
api_key="sk-ant-...",
base_url="https://adaptiveapi.example.com/anthropic/v1/rt_yourtenant_xxxxx",
)
message = client.messages.create(
model="claude-3-7-sonnet-latest",
max_tokens=1024,
system="Tu es un assistant serviable.",
messages=[{"role": "user",
"content": "Explique-moi le théorème de Pythagore."}],
extra_headers={"X-AdaptiveApi-Target-Lang": "fr"},
)
What is supported
- Messages API. System prompts, multi-turn, streaming, tool use.
- System prompts. Translated alongside user messages so the model receives a consistent working language.
- Tool use blocks.
inputJSON is walked the same way as OpenAI'sarguments. - Content blocks. Text blocks are translated. Image blocks pass through.
Other providers
Cohere, Mistral, Azure OpenAI, Together, Groq, your local vLLM, and anything else with an HTTP+JSON shape goes through the Generic JSON API instead. You describe which JSON paths carry human text and AdaptiveAPI handles the round trip.
Tip. If a provider implements an OpenAI-compatible endpoint (Together, Groq, Mistral La Plateforme, vLLM, etc.), you can often use the OpenAI surface above by setting the route's upstream to their base URL. Saves writing a generic-route definition.
Headers and overrides
Every X-AdaptiveApi-* header is stripped before the request reaches the upstream. They never leak into your model context. The headers you can use:
| Header | Example | Purpose |
|---|---|---|
X-AdaptiveApi-Target-Lang | de | What the caller speaks. |
X-AdaptiveApi-Source-Lang | en | What the model thinks in. |
X-AdaptiveApi-Mode | bidirectional | Direction toggle. |
X-AdaptiveApi-Style-Rule | s_marketing | Apply a style rule. See Style rules. |
X-AdaptiveApi-Glossary | g_default | Apply a glossary. |
Full list lives in Routes and tokens.