# Set up System Duo in a coding agent > System Duo (https://app.vllm-sr.ai) is vLLM Semantic Router's free service. Its System Two serves `vllm-sr/auto`: one model name that sends every request to the right open model (today Norn-1), through the APIs coding agents speak (Anthropic Messages, OpenAI Responses, Chat Completions). This guide is for a coding agent: follow it to switch the harness you run in (Claude Code, Codex, OpenCode, OpenClaw, Cursor or DeepSeek Harness) to `vllm-sr/auto`, with a free API key. The user asked you to "set up duo". Do the steps in order, and say what you will change before you change it. If the harness is already set up for System Two, from an earlier run or by hand, do them anyway: keep the user's key, and bring the settings up to date with step 3, where every line is needed. This guide changes as System Two learns what each harness needs, so running it again is how a setup stays current. ## 1. Ask first - Tell the user: a key is free and needs no account, and making one accepts the terms of use (https://app.vllm-sr.ai/terms): research and evaluation only, no commercial use. System Two logs requests as https://app.vllm-sr.ai/docs#logging describes. Go on only with their OK. - Work out which harness you run in; if you cannot tell, ask. DeepSeek Harness gets its own key: go straight to its section in step 3. ## 2. Get a key If the user already has a key (`sk-vsr-` and 43 letters and digits), use it. Otherwise make one. This Python 3 script (standard library only) does the same small proof of work as the button on the home page, saves the key to `~/.config/vllm-sr/key`, readable by the user only, and prints only its prefix: ```python import hashlib, itertools, json, os, pathlib, urllib.request BASE = "https://app.vllm-sr.ai" def post(path, body=None): data = b"" if body is None else json.dumps(body).encode() headers = {} if body is None else {"content-type": "application/json"} with urllib.request.urlopen(urllib.request.Request(BASE + path, data=data, headers=headers)) as res: return json.load(res) challenge = post("/api/keys/challenge") target = 1 << (256 - challenge["difficulty"]) prefix = challenge["challenge"] + ":" nonce = next(n for n in itertools.count() if int.from_bytes(hashlib.sha256(f"{prefix}{n}".encode()).digest(), "big") < target) key = post("/api/keys", {"challenge": challenge["challenge"], "nonce": str(nonce), "accept_terms": True})["api_key"] path = pathlib.Path.home() / ".config" / "vllm-sr" / "key" path.parent.mkdir(parents=True, exist_ok=True) path.write_text(key + "\n") os.chmod(path, 0o600) print("saved", key[:11] + "...", "to", path) ``` - The key is shown once; the service keeps only its hash. Never put it in a chat, a repository or a web page. - `429 key_creation_limited` means this network made too many keys lately: wait for `Retry-After`, or ask the user to make one at https://app.vllm-sr.ai/#key and save it to `~/.config/vllm-sr/key`. ## 3. Point the harness at System Two The model is `vllm-sr/auto`. Below, `KEY` stands for the contents of `~/.config/vllm-sr/key`. Keep the user's other settings: add or change only the lines shown, and note the old values so the user can switch back. Your harness may ask the user before you read or edit files outside the project, such as its own settings and the key file (OpenCode's `external_directory` permission, Codex's sandbox, Claude Code's protected settings). Say what you will change and let the user approve. If your session cannot ask (a non-interactive run), do not retry: show the user the exact lines to add, and the file they go in. ### Claude Code Merge into the `env` object of `~/.claude/settings.json` (create the file if there is none; when `CLAUDE_CONFIG_DIR` is set, use the `settings.json` there): ```json { "env": { "ANTHROPIC_BASE_URL": "https://app.vllm-sr.ai", "ANTHROPIC_AUTH_TOKEN": "KEY", "ANTHROPIC_MODEL": "vllm-sr/auto", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "vllm-sr/auto", "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1", "CLAUDE_CODE_GATEWAY_HINT_HEADERS": "1", "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1000000" } } ``` - `ANTHROPIC_BASE_URL` has no `/v1`. The haiku model serves Claude Code's small background requests, which otherwise ask for a Claude model and are refused. - `CLAUDE_CODE_GATEWAY_HINT_HEADERS=1` lets System Two send session titles, compactions and Explore subagents to a cheaper setting. - Claude Code does not recognize `vllm-sr/auto` and would guess its context window; `CLAUDE_CODE_MAX_CONTEXT_TOKENS` gives it the real one (1M tokens), so it compacts a long session before the session outgrows it. To compact earlier, the user can run `/autocompact 200k` in Claude Code. - An `ANTHROPIC_API_KEY` in the environment takes precedence: tell the user to unset it. - Claude Code protects its own settings files, so the edit asks the user for approval. If your session cannot ask (for example under `claude -p`), write the merged file to `~/.config/vllm-sr/claude-settings.json` and give the user the one command that copies it into place. - The settings file now holds the key: keep it out of repositories. The user starts a new session with `claude`. ### Codex At the top of `~/.codex/config.toml`, before any `[table]`, and the provider table after it: ```toml model = "vllm-sr/auto" model_provider = "vllm-sr" web_search = "disabled" model_context_window = 1000000 [model_providers.vllm-sr] name = "vLLM Semantic Router" base_url = "https://app.vllm-sr.ai/v1" env_key = "VLLM_SR_API_KEY" wire_api = "responses" ``` Codex reads the key from `VLLM_SR_API_KEY`. With the user's OK, add this line to their shell profile (`~/.zshrc`, `~/.bashrc`, ...); then they open a new terminal and run `codex`: ```sh export VLLM_SR_API_KEY="$(cat ~/.config/vllm-sr/key)" ``` System Two has no web search yet, hence `web_search = "disabled"`. Codex cannot look up `vllm-sr/auto`'s context window; `model_context_window` gives it, and Codex then compacts a long session by itself at about 90% of it. When it starts, Codex may print `Model metadata for vllm-sr/auto not found. Defaulting to fallback metadata`. That is expected and harmless: Codex has no built-in entry for this model, so it uses its general settings, with the window from `model_context_window`, and it works as usual. ### OpenCode Add the provider to `~/.config/opencode/opencode.json` (or to the project's `opencode.json`) and set the model: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "vllm-sr": { "npm": "@ai-sdk/openai-compatible", "name": "vLLM Semantic Router", "options": { "baseURL": "https://app.vllm-sr.ai/v1", "apiKey": "{file:~/.config/vllm-sr/key}" }, "models": { "auto": { "id": "vllm-sr/auto", "name": "vllm-sr/auto", "attachment": true, "modalities": { "input": ["text", "image"], "output": ["text"] }, "limit": { "context": 1000000, "output": 32000 } } } } }, "model": "vllm-sr/auto" } ``` OpenCode names a model by its provider and its key, so `vllm-sr/auto` is the `auto` entry of the `vllm-sr` provider; its `id` is the name System Two receives. `attachment` and `modalities` tell OpenCode that the model reads pictures: without them OpenCode replaces an attached picture with a note that the model cannot read it. `limit` gives OpenCode the context window and the longest answer, which it cannot look up for this model, so it compacts a session as the conversation nears the window. The user restarts `opencode`, or picks the model with `/models`. ### OpenClaw Add the provider to `~/.openclaw/openclaw.json` (keep the user's other settings; with `openclaw config set` the same lines merge in) and set the default model: ```json { "models": { "providers": { "vllm-sr": { "baseUrl": "https://app.vllm-sr.ai/v1", "apiKey": "${VLLM_SR_API_KEY}", "api": "openai-completions", "models": [ { "id": "vllm-sr/auto", "name": "vllm-sr/auto", "reasoning": true, "input": ["text", "image"], "contextWindow": 1000000, "maxTokens": 32000, "responseModelEquivalent": true, "compat": { "supportsUsageInStreaming": true, "supportsPromptCacheKey": true } } ] } } }, "agents": { "defaults": { "model": { "primary": "vllm-sr/vllm-sr/auto" } } } } ``` OpenClaw reads the key from `VLLM_SR_API_KEY`: with the user's OK, add `export VLLM_SR_API_KEY="$(cat ~/.config/vllm-sr/key)"` to their shell profile, or put the variable in the environment of the OpenClaw gateway. A model reference is the provider and the model's `id`, so `vllm-sr/vllm-sr/auto` is the `vllm-sr/auto` model of the `vllm-sr` provider. `input` lets OpenClaw send pictures (its `view_image` tool) to the model. `contextWindow` and `maxTokens` give it the window and the longest answer, which it cannot look up for this model, so it compacts a session in time. `responseModelEquivalent` tells it that System Two picks the model itself, so an answer from another model of the pool is not a model change. `supportsPromptCacheKey` makes OpenClaw send its session key with each request, which keeps a session on one model and groups its turns. `supportsUsageInStreaming` returns token usage. Then restart the gateway (`openclaw gateway restart`) and check with `openclaw models list`. OpenClaw's sub-agents (`sessions_spawn`) run through the gateway, not with `openclaw agent --local`. ### Cursor Cursor keeps these settings in its app, so give the user the steps: 1. Cursor Settings > Models > API Keys: turn on the OpenAI API Key and paste the key. 2. Turn on Override OpenAI Base URL, enter `https://app.vllm-sr.ai/v1` and verify. 3. Add a custom model named `vllm-sr/auto`, turn it on, and pick it in the chat or agent model menu. Cursor sends these requests from its own servers, as Chat Completions. While the override is on, Cursor's built-in OpenAI models (the ones in its model menu) are sent to System Two too, and System Two answers them with `vllm-sr/auto`: the answer's `model` names the model that served it, so pick `vllm-sr/auto` to know what you get, and turn the override off to use Cursor's own models again. Cursor sends no session id, so System Two keeps a conversation together by how it starts. Some Cursor features (Tab completion among them) keep using Cursor's own models. ### DeepSeek Harness (dsh) The `@vllm-sr/dsh` plugin sets everything up and gets its own free key on its first start, so step 2 is not needed (step 4 says where it keeps the key): ```sh npm install -g @deepseek-ai/dsh pnpm dsh plugin --profile web add @vllm-sr/dsh dsh web ``` For the headless profile: `dsh plugin --profile headless add @vllm-sr/dsh`. `vllm-sr/auto` plans and acts; System One answers the small questions around it. ## 4. Check Two small requests with the key: one in words, and one with a picture (a small PNG, red on the left and blue on the right, inline as base64): ```sh KEY="$(cat ~/.config/vllm-sr/key)" curl -s https://app.vllm-sr.ai/v1/chat/completions \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"model": "vllm-sr/auto", "messages": [{"role": "user", "content": "Reply with the word ready."}], "max_tokens": 64}' curl -s https://app.vllm-sr.ai/v1/chat/completions \ -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \ -d '{"model": "vllm-sr/auto", "max_tokens": 1024, "messages": [{"role": "user", "content": [ {"type": "text", "text": "Which two colours does this picture show? Answer in a few words."}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAwCAIAAAAuKetIAAAAQ0lEQVR42u3PsQkAAAzDsPz/dPpCl2wCzwalybTxvgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+HaxDfSmyAK70QAAAABJRU5ErkJggg=="}}]}]}' ``` DeepSeek Harness keeps its key elsewhere: the plugin makes it when `dsh web` (or `dsh headless`) first starts and saves it in `~/.dsh/.env` (`$DSH_HOME/.env` when `DSH_HOME` is set), as `VLLM_SR_API_KEY=...`; a key the user gave DeepSeek Harness themselves stays where they put it. So for DeepSeek Harness, have the user start it once, then run the same two requests with this first line instead: ```sh KEY="$(sed -n 's/^VLLM_SR_API_KEY=//p' "${DSH_HOME:-$HOME/.dsh}/.env" | tail -n 1)" ``` A JSON answer with `choices` to each means the key and the model work, and the second answer names red and blue, so pictures reach the model. For OpenClaw, also run one turn through it: `openclaw agent --message "Reply with the word ready."` answers `ready`. Cursor runs on Cursor's servers, so the two requests above only check the key. Give the user this check to run in Cursor: start a new Agent chat with `vllm-sr/auto` in a project, ask it to read one file and tell what it does (a tool call, then an answer about the file), then attach a screenshot and ask what it shows. Both answer, and the second describes the picture. Then pick one of Cursor's built-in models with the override still on and send one message: it is answered too, by `vllm-sr/auto`. Then tell the user what you changed, how to start their harness on `vllm-sr/auto`, and how to switch back (put the old values back). ## Good to know - One key works for System One and System Two. Each key has its own budget; the live limits are at https://app.vllm-sr.ai/pt/api/info. Every `429` carries `Retry-After`: back off and retry. - Check a key on https://app.vllm-sr.ai/keys, or with `GET https://app.vllm-sr.ai/api/keys/self` (System One's limits and usage) and `GET https://app.vllm-sr.ai/pt/api/keys/self` (System Two's) and the key. `DELETE https://app.vllm-sr.ai/api/keys/self` revokes it and keeps its data (System One refuses it at once, System Two within a minute); `POST https://app.vllm-sr.ai/api/keys/self/forget` revokes it and deletes its data on both systems. - Sessions need no setup: each harness's own session header keeps a session on one model (OpenClaw's session key, with `supportsPromptCacheKey`; Cursor sends none, so a conversation is kept together by how it starts). - Setting up by hand, every line explained: https://app.vllm-sr.ai/docs#coding-agents. Service status: https://app.vllm-sr.ai/status.