Keyway Integration Guide
A single db_sk_ key lets you connect Claude Code (and any OpenAI/Anthropic SDK client) to Keyway, routing requests across DeepSeek / MiniMax / Volcengine Ark / Zhipu GLM / Qwen and more — just pick a model alias, no config changes needed.
Contents
1. How it works
Keyway is a routing gateway. Clients send requests using OpenAI or Anthropic protocol; Keyway resolves the model alias to the configured upstream provider and forwards:
- OpenAI protocol clients →
POST /v1/chat/completions→ Keyway routes to an OpenAI-compatible upstream. - Anthropic protocol clients →
POST /v1/messages→ Keyway routes to an Anthropic-compatible upstream.
All upstream real API keys are stored encrypted on the Keyway server. Clients only hold a single db_sk_ self-issued key.
2. Keyway endpoints
| Purpose | Value |
|---|---|
| Base URL (OpenAI SDK) | http://localhost:9233/v1 |
| Base URL (Anthropic SDK / Claude Code) | http://localhost:9233 |
| OpenAI chat completions | POST /v1/chat/completions |
| OpenAI models list | GET /v1/models |
| Anthropic messages | POST /v1/messages |
| Anthropic token count | POST /v1/messages/count_tokens |
| Generic generation (image/video/3D) | POST /v1/generations |
| Authentication | Authorization: Bearer db_sk_… |
3. Connecting Claude Code
Step 1: Create a self-issued key
Log in to the admin UI, open a group, switch to the "API Keys" tab, create a key. The plaintext db_sk_… is shown once (you can re-retrieve it later as admin). Then click Connect on a route or key to copy a ready-made snippet with everything filled in.
Step 2: Configure Claude Code
Use project-level config. Create .claude/settings.local.json in your project root:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:9233",
"ANTHROPIC_AUTH_TOKEN": "db_sk_your-key-here",
"ANTHROPIC_MODEL": "deepseek-v4-pro",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-pro",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro"
}
}
| Field | Notes |
|---|---|
ANTHROPIC_BASE_URL | Gateway address without trailing slash. Claude Code SDK auto-appends /v1/messages. |
ANTHROPIC_AUTH_TOKEN | Use AUTH_TOKEN (sends Authorization: Bearer). Avoid ANTHROPIC_API_KEY which has interactive confirmation issues. |
ANTHROPIC_MODEL | Main model = route alias. Can also /model <alias> in-session. |
ANTHROPIC_DEFAULT_*_MODEL | Must all be valid aliases. Background tasks use these; leaving default claude-haiku-… will 404 if no such alias exists. |
.claude/settings.local.json to your .gitignore — otherwise your key enters git.
Step 3: Verify
Test with curl first (bypasses Claude Code for easier debugging):
curl -X POST http://localhost:9233/v1/messages \
-H "Authorization: Bearer db_sk_your-key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-v4-pro","max_tokens":16,"messages":[{"role":"user","content":"Reply with OK."}]}'
Should return {"id":"msg_…","type":"message","content":[{"type":"text","text":"…"}],…}.
4. Connecting OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:9233/v1",
api_key="db_sk_your-key-here",
)
resp = client.chat.completions.create(
model="deepseek-v4-pro", # your route alias
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
For streaming, add stream=True. The /v1/models endpoint lists all enabled route aliases as models.
5. Upstream providers
DeepSeek
OpenAI Base URL: https://api.deepseek.com/v1
| Model ID | Reasoning | Streaming | Tools | Context |
|---|---|---|---|---|
deepseek-chat | No | Yes | Yes | 64K |
deepseek-reasoner | Yes | Yes | Yes | 64K |
OpenAI
OpenAI Base URL: https://api.openai.com/v1
| Model ID | Reasoning | Streaming | Tools |
|---|---|---|---|
gpt-4o | No | Yes | Yes |
gpt-4o-mini | No | Yes | Yes |
o3-mini | Yes | Yes | Yes |
Anthropic
Anthropic Base URL: https://api.anthropic.com (Keyway appends /v1/messages)
| Model ID | Reasoning | Streaming | Tools |
|---|---|---|---|
claude-sonnet-4-20250514 | Extended thinking | Yes | Yes |
claude-opus-4-20250514 | Extended thinking | Yes | Yes |
claude-haiku-4-20250506 | No | Yes | Yes |
Volcengine Ark (Doubao)
OpenAI Base URL: https://ark.cn-beijing.volces.com/api/v3
| Model ID | Reasoning | Streaming | Tools |
|---|---|---|---|
doubao-seed-1-6-250615 | No | Yes | Yes |
doubao-seed-1-6-thinking-250615 | Yes | Yes | Yes |
Zhipu GLM
OpenAI Base URL: https://open.bigmodel.cn/api/paas/v4
| Model ID | Reasoning | Streaming | Tools |
|---|---|---|---|
glm-4-plus | No | Yes | Yes |
glm-4-flash | No | Yes | Yes |
Qwen (DashScope)
OpenAI Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1
| Model ID | Streaming | Tools |
|---|---|---|
qwen-plus | Yes | Yes |
qwen-turbo | Yes | Yes |
6. Troubleshooting
404 "model not found"
Alias is misspelled, route is disabled, or provider is disabled. Check the admin UI or run "E2E Test" on the Logs page.
404 "model is bound to X provider, not openai/anthropic"
Your route's provider protocol doesn't match the client's protocol. An OpenAI client needs an OpenAI-protocol provider; an Anthropic client needs an Anthropic-protocol provider.
502 upstream error
Check the request logs in the admin UI — they show the upstream status code and error message. Common causes: invalid upstream API key, wrong model name, or the model doesn't support the requested feature.
Claude Code can't connect
- Ensure
ANTHROPIC_BASE_URLhas no trailing slash. - Use
ANTHROPIC_AUTH_TOKENnotANTHROPIC_API_KEY. - Make sure all
ANTHROPIC_DEFAULT_*_MODELvalues are valid aliases.