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:

  1. Detect protocol — determine the client's format from the URL path (/anthropic/*, /openai/*, /gemini/*)
  2. Match upstream — find the corresponding upstream channel by model name
  3. Convert format — if the client format ≠ the upstream format, automatically convert the request and response
  4. Forward transparently — completely invisible to the client, just like calling the native API

Supported conversion paths

Request conversion

Client formatUpstream formatScenario
Anthropic MessagesOpenAI ChatClaude Code calling DeepSeek / GPT-5
OpenAI ChatAnthropic MessagesCodex calling Claude
OpenAI ChatGeminiOpenAI SDK tools calling Gemini
GeminiOpenAI ChatGemini CLI calling DeepSeek
OpenAI ResponsesOpenAI ChatResponses API calling a Chat model
OpenAI ChatOpenAI ResponsesChat 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:

ProtocolDescription
chatOpenAI Chat Completions API
responsesOpenAI Responses API
anthropicAnthropic Messages API
geminiGoogle Gemini generateContent API

Model compatibility

Model typeChat APIEmbeddingImageAudio
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.