slug: protocols
Protocol Adapters
Agents and upstreams speak different protocols. OAR's job is to make any agent talk to any upstream — passing through when they agree, converting when they don't.
The protocol matrix
| Agent | Protocol sent | Upstream protocol | Adapter? |
|---|---|---|---|
| Claude Code → Claude Sonnet | Anthropic | Anthropic | ✗ pass-through |
| Claude Code → GLM-5.2 (fallback) | Anthropic | OpenAI | ✓ convert |
| Hermes → GPT-4o | OpenAI | OpenAI | ✗ pass-through |
| Codex → Claude Sonnet | Codex | Anthropic | ✓ convert |
Agent → protocol matches → pass-through forward (zero overhead)
↘ protocol differs → adapter converts → forward
Adapter paths
OAR ships adapters for every conversion path needed by the supported agents, in both streaming (SSE) and non-streaming flavours:
| Path | Adapter | Streams |
|---|---|---|
| Anthropic → OpenAI | a2o | HTTP + Stream |
| Codex Responses → OpenAI | r2o | HTTP + Stream |
| Codex Responses → Anthropic | r2a | HTTP + Stream |
| Google AI → OpenAI | g2o | HTTP + Stream |
| Google AI → Anthropic | g2a | HTTP + Stream |
The naming convention is client→upstream: a2o reads as "anthropic to openai".
Vendor multi-protocol shortcuts
Before converting, OAR prefers vendor presets that natively support the target protocol. Instead of converting the protocol, it just switches the endpoint.
Scenario: Claude Code wants to use a DeepSeek model
User-configured DeepSeek instance protocol = openai
Current request protocol = anthropic (sent by Claude Code)
1. Look up vendor preset: DeepSeek supports anthropic
2. Auto-switch: https://api.deepseek.com/anthropic/v1/messages
3. Direct connection, zero protocol conversion
Fallback: vendor doesn't support the target protocol → run the adapter
When the vendor preset library doesn't apply (custom platform, private deployment), the adapter is always used.
Protocol auto-detection
After you enter a base_url, OAR probes the supported protocols automatically:
Enter base_url: https://api.xxx.com/v1
↓
Probe requests
├─ POST /chat/completions → 200/401/400/429 → ✅ OpenAI
├─ POST /messages → 200/401/400/429 → ✅ Anthropic
└─ neither responds → manual protocol selection
The detection result is written back into the platform instance's protocol field, so you don't have to pick manually. Manual override is still available.
Vendor preset library
Common vendors ship with their base_url and supported protocols pre-filled:
DeepSeek → openai (api.deepseek.com/v1)
+ anthropic (api.deepseek.com/anthropic)
Anthropic → anthropic (api.anthropic.com/v1)
OpenAI → openai (api.openai.com/v1)
Volcano → openai (ark.cn-beijing.volces.com/api/v3)
SiliconFlow → openai (api.siliconflow.cn/v1)
MiniMax → openai (api.minimaxi.com/v1)
Streaming
Every proxy request supports SSE streaming pass-through — no buffering, no conversion of the stream itself. The proxy writes each upstream chunk to the response immediately with Transfer-Encoding: chunked and Content-Type: text/event-stream, and relays the [DONE] marker. When the client disconnects, the upstream request is aborted.
Protocol adapters that produce converted output also emit SSE-formatted chunks, so the client always sees a real stream.
See Supported Agents for the full list of agents and their recommended base_urls.