Keyway Keyway Docs

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:

All upstream real API keys are stored encrypted on the Keyway server. Clients only hold a single db_sk_ self-issued key.

Protocol matching: OpenAI inbound requires an OpenAI-protocol provider; Anthropic inbound requires an Anthropic-protocol provider. Cross-protocol returns 404. Make sure your route's provider protocol matches the client's protocol.

2. Keyway endpoints

PurposeValue
Base URL (OpenAI SDK)http://localhost:9233/v1
Base URL (Anthropic SDK / Claude Code)http://localhost:9233
OpenAI chat completionsPOST /v1/chat/completions
OpenAI models listGET /v1/models
Anthropic messagesPOST /v1/messages
Anthropic token countPOST /v1/messages/count_tokens
Generic generation (image/video/3D)POST /v1/generations
AuthenticationAuthorization: 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"
  }
}
FieldNotes
ANTHROPIC_BASE_URLGateway address without trailing slash. Claude Code SDK auto-appends /v1/messages.
ANTHROPIC_AUTH_TOKENUse AUTH_TOKEN (sends Authorization: Bearer). Avoid ANTHROPIC_API_KEY which has interactive confirmation issues.
ANTHROPIC_MODELMain model = route alias. Can also /model <alias> in-session.
ANTHROPIC_DEFAULT_*_MODELMust all be valid aliases. Background tasks use these; leaving default claude-haiku-… will 404 if no such alias exists.
Add .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

Keyway config: Create a provider with the Base URL and API Key, then create a route with your chosen alias and the exact upstream model ID from the tables below. Model IDs change frequently — always verify on the provider's console.

DeepSeek

OpenAI Base URL: https://api.deepseek.com/v1

Model IDReasoningStreamingToolsContext
deepseek-chatNoYesYes64K
deepseek-reasonerYesYesYes64K

OpenAI

OpenAI Base URL: https://api.openai.com/v1

Model IDReasoningStreamingTools
gpt-4oNoYesYes
gpt-4o-miniNoYesYes
o3-miniYesYesYes

Anthropic

Anthropic Base URL: https://api.anthropic.com (Keyway appends /v1/messages)

Model IDReasoningStreamingTools
claude-sonnet-4-20250514Extended thinkingYesYes
claude-opus-4-20250514Extended thinkingYesYes
claude-haiku-4-20250506NoYesYes

Volcengine Ark (Doubao)

OpenAI Base URL: https://ark.cn-beijing.volces.com/api/v3

Model IDReasoningStreamingTools
doubao-seed-1-6-250615NoYesYes
doubao-seed-1-6-thinking-250615YesYesYes

Zhipu GLM

OpenAI Base URL: https://open.bigmodel.cn/api/paas/v4

Model IDReasoningStreamingTools
glm-4-plusNoYesYes
glm-4-flashNoYesYes

Qwen (DashScope)

OpenAI Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1

Model IDStreamingTools
qwen-plusYesYes
qwen-turboYesYes

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