deployment-{id}) or an
alias. Claude Code appends /v1/messages itself, so the base URL
must not end in /v1.
Set it up
1
Open a terminal
Open a new terminal window. Everything below runs in this one shell session, so keep
it open while you use Claude Code. (To make it permanent, see
Persist the configuration at the end.)
2
Clear any existing Anthropic API key
If
ANTHROPIC_API_KEY is set, it takes precedence and Claude Code will try to reach
Anthropic instead of Valkyrie. Unset it:3
Set the base URL (no /v1, no quotes inside the value)
Use your deployment slug or an alias. Do not include
/v1 — Claude Code adds
/v1/messages on its own.acme/qwen-coder is only an example: acme is your account handle and
qwen-coder is an alias you created. Don’t know yours, or haven’t made one? See
Aliases — it shows where to create and find them in the
dashboard (with a screenshot of the Alias Management screen). Prefer an alias over a
raw deployment-{id}: a deployment id points at a single instance and stops working
the moment that deployment is replaced, while an alias stays stable and can be
re-pointed. If you haven’t set one up yet, use your deployment’s slug from
Dashboard → Models instead.Which URL do I use? Claude Code uses the Anthropic base: your slug or alias
with no
/v1 on the end, because Claude Code appends /v1/messages itself. The
/v1 form of the same deployment is the OpenAI-compatible base, for a different
set of clients:Same alias (or deployment), two base URLs. Give Claude Code the
/v1 form and the
path doubles to /v1/v1/messages, which fails.4
Set the auth token
Use a deployment key (
vk_dep_...) from your dashboard. ANTHROPIC_AUTH_TOKEN
sends it as Authorization: Bearer and avoids Claude Code’s one-time custom-key
approval prompt. Do not set both ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY.5
Find your model name
Claude Code sends a The response lists your model, for example:Note the
model field on every request. Ask your deployment which model
id it serves:id (the model name) and max_model_len (the context window) — you need
both in the next step.6
Set the model and context limit
Set
ANTHROPIC_MODEL to the id from the previous step. Set
CLAUDE_CODE_MAX_CONTEXT_TOKENS to your model’s max_model_len.CLAUDE_CODE_MAX_CONTEXT_TOKENS is important. Without it, Claude Code assumes a
Claude-sized context window (200k) and will overflow a smaller open model,
producing truncation or request errors. Set it to your deployment’s real context
length.7
Launch Claude Code
8
Verify the connection
Inside Claude Code, run:Confirm all of the following:
- Anthropic base URL is your Valkyrie URL (ends in the slug/alias, not
/v1). - The active credential source is
ANTHROPIC_AUTH_TOKEN. - The model is your model id.
Show your model name (instead of “Opus”)
Claude Code’s status line knows the Claude model names (Opus, Sonnet, Haiku). WhenANTHROPIC_MODEL is a name it doesn’t recognize, it falls back to displaying Opus
even though every request still goes to your Valkyrie model. It’s cosmetic, not a
misconfiguration, but you can make the UI show the real name by registering your model
as a custom option:
/model, and the status line then shows
the name you set.
When Claude Code points at a Valkyrie base URL, all of its traffic goes to your
one deployed model, including background work like conversation titles and summaries.
There is no separate small/fast model quietly reaching Anthropic. Size the deployment
for that full load.
Revert to normal Claude
The variables above only affect the shell session (or profile) where you set them. To go back to Anthropic’s Claude:1
Unset the Valkyrie variables
In the same terminal:(Opening a brand-new terminal window also works if you never persisted them.)
2
Remove any persisted values
If you added these to your shell profile (
~/.zshrc, ~/.bashrc) or to
~/.claude/settings.json, delete those lines/keys too, otherwise they come back in
every new session.3
Sign back in and restart
Restart Claude Code and, if needed, sign in again:Run
/status to confirm the base URL is back to Anthropic’s default and your
claude.ai login (or ANTHROPIC_API_KEY) is the active credential.Persist the configuration
To avoid re-exporting every session, keep the non-secret values in~/.claude/settings.json and leave the token in your environment
(settings.json does not expand $VARIABLES, so never put a raw key there if you can
avoid committing it):
export ANTHROPIC_AUTH_TOKEN="vk_dep_..." in your shell profile (or a sourced
secrets file), and keep ANTHROPIC_API_KEY unset.
Troubleshooting
"... cannot be parsed as a URL"
"... cannot be parsed as a URL"
Your
ANTHROPIC_BASE_URL contains literal quote characters, e.g. the value is
"https://.../deployment-227" including the ". A URL cannot contain a ", so
the request fails before it’s sent. Re-export the value with the quotes wrapping it,
not inside it:Requests hit /v1/v1/messages (404 / not found)
Requests hit /v1/v1/messages (404 / not found)
Your base URL ends in
/v1. Claude Code appends /v1/messages itself, so the base
URL must stop at the slug or alias. Use .../deployment-227, not
.../deployment-227/v1. The /v1 form is the OpenAI-compatible base URL, used
by Qwen Code, the OpenAI SDK, and LiteLLM, not by Claude Code.It's still talking to Anthropic, not Valkyrie
It's still talking to Anthropic, not Valkyrie
ANTHROPIC_API_KEY is still set and takes precedence. Run unset ANTHROPIC_API_KEY,
then restart Claude Code. Confirm with /status that the base URL is your Valkyrie
URL and the credential source is ANTHROPIC_AUTH_TOKEN.Context overflow or truncation errors
Context overflow or truncation errors
CLAUDE_CODE_MAX_CONTEXT_TOKENS is unset or larger than your model supports. Set it
to your deployment’s max_model_len (from the /v1/models call above).503 errors, or the connection drops in and out
503 errors, or the connection drops in and out
A 503 means the deployment isn’t reachable at that moment. It is almost never Claude
Code’s fault — check the deployment:
- Is it actually running? Open Dashboard → Models and confirm the deployment you pointed at is serving. A stopped, paused, or terminated deployment returns 503/404 for every request. This is the most common cause of a base URL that “used to work.”
- Cold start / restart window. A deployment runs on a GPU instance that has to boot; while it’s coming up (or restarting after a crash) requests briefly 503. Wait for Dashboard → Models to show it healthy, then retry.
- Empty wallet. If your balance reaches zero, the deployment is paused for billing and returns 503 until you add credit (Dashboard → Wallet) and it resumes.
The status line shows "Opus" while I use Valkyrie
The status line shows "Opus" while I use Valkyrie
Cosmetic. Claude Code falls back to the “Opus” label for model names it doesn’t
recognize; requests still go to your Valkyrie model (confirm the base URL and model
id with
/status). To display the real name, set the
ANTHROPIC_CUSTOM_MODEL_OPTION* variables in
Show your model name.Looking to let Claude Code operate Valkyrie (deploy models, read logs, manage
jobs) rather than use one as its model? That’s the MCP server, see
Set up the MCP server. The two integrations are
independent and can be used together.