Protocol Adaptation
How TokenLink translates between different AI API formats
Protocol adaptation is TokenLink's core capability. It lets you call any model with any Agent tool — whether or not they are natively compatible.
How it works
Client (Claude Code) TokenLink Upstream (DeepSeek)
│ │ │
│ Anthropic Messages API │ │
│ /anthropic/v1/messages │ │
├───────────────────────────►│ │
│ │ Convert to OpenAI Chat API │
│ │ /chat/completions │
│ ├──────────────────────────────►│
│ │ │
│ │ OpenAI Chat Response │
│ │◄──────────────────────────────┤
│ │ │
│ Convert to Anthropic │ │
│ Message Response │ │
│◄───────────────────────────┤ │
│ │ │After TokenLink receives a client request:
- Detect protocol — determine the client's format from the URL path (
/anthropic/*,/openai/*,/gemini/*) - Match upstream — find the corresponding upstream channel by model name
- Convert format — if the client format ≠ the upstream format, automatically convert the request and response
- Forward transparently — completely invisible to the client, just like calling the native API
Supported conversion paths
Request conversion
| Client format | → | Upstream format | Scenario |
|---|---|---|---|
| Anthropic Messages | → | OpenAI Chat | Claude Code calling DeepSeek / GPT-5 |
| OpenAI Chat | → | Anthropic Messages | Codex calling Claude |
| OpenAI Chat | → | Gemini | OpenAI SDK tools calling Gemini |
| Gemini | → | OpenAI Chat | Gemini CLI calling DeepSeek |
| OpenAI Responses | → | OpenAI Chat | Responses API calling a Chat model |
| OpenAI Chat | → | OpenAI Responses | Chat request converted to the new Responses format |
Streaming conversion
Streaming (SSE) requests are also supported. Each SSE event is converted from the upstream format to the client format as it is forwarded.
Specific supported conversions:
- Anthropic SSE → OpenAI SSE: Claude streaming events converted to OpenAI format
- OpenAI SSE → Anthropic SSE: OpenAI streaming converted to Anthropic format
- Gemini SSE → OpenAI SSE: Gemini streaming converted to OpenAI format
- OpenAI Chat SSE → OpenAI Responses SSE: Chat streaming events converted to the Responses format (including
event:lines)
Native protocol (Passthrough)
If the upstream channel natively supports the protocol format of the client request, TokenLink passes it through directly without any format conversion.
For example: when Claude Code sends an Anthropic-format request to call a real Claude model, the upstream is already native Anthropic format → forwarded directly, with zero overhead.
A channel's protocol support is configured via the protocols field:
| Protocol | Description |
|---|---|
chat | OpenAI Chat Completions API |
responses | OpenAI Responses API |
anthropic | Anthropic Messages API |
gemini | Google Gemini generateContent API |
Model compatibility
| Model type | Chat API | Embedding | Image | Audio |
|---|---|---|---|---|
| GPT-5 | ✅ | ✅ | ✅ | ✅ |
| Claude | ✅ | — | — | — |
| Gemini | ✅ | — | — | — |
| DeepSeek | ✅ | — | — | — |
| text-embedding-* | — | ✅ | — | — |
| dall-e-* | — | — | ✅ | — |
| tts-/whisper- | — | — | — | ✅ |
What this means for developers
You don't need to worry about any of these conversion details. Just remember one thing:
Use Claude Code to call DeepSeek, Codex to call Gemini, Gemini CLI to call GPT-5 — it all works out of the box.