> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sailresearch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Claude Code with Sail

> Run Claude Code on GLM-5.3 via Sail: one command, no Anthropic account.

[Claude Code](https://code.claude.com) speaks the Anthropic Messages API to
whatever endpoint `ANTHROPIC_BASE_URL` points at. Sail serves that API for
GLM-5.3 (system prompts, tool calling, and streaming included), so pointing
Claude Code at Sail is just environment configuration. The command below does
it in one step.

<Note>
  Want to keep Claude Code on its current model and send selected work to Sail
  instead? Install the [Sail plugin for coding agents](/coding-agents).
</Note>

## Quickstart (terminal)

Install Claude Code if you haven't, then launch it routed to Sail:

```bash theme={null}
npm install -g @anthropic-ai/claude-code            # once
curl -fsSL https://cli.sailresearch.com/install.sh | sh   # once
sail auth login                                     # once
sail claude
```

That starts `claude` on **GLM-5.3**. Nothing on your machine is modified: the
routing applies to that one session, so your Claude Code setup and your
Anthropic credentials are left alone. If you prefer not to store a key, set
`SAIL_API_KEY` in your environment and skip `sail auth login`.

## Three commands, three scopes

| Command | What it affects |
| - | - |
| `sail claude` | This session only. Does not write anything. |
| `sail claude on` | Every Claude Code that reads your user settings, including a bare `claude` and the VS Code extension. |
| `sail claude off` | Undoes `sail claude on`. |

You never need `sail claude on` to use `sail claude`. Turning it on is only for
reaching the entry points you do not launch yourself, and `sail claude` keeps
working after you turn it off.

One exception to "every Claude Code": routing set in a repository's own
`.claude/settings.json` takes precedence over your user settings, so a session
started there keeps using that repository's routing. Run
`sail claude on --project` inside such a repository to route it too.

## Trusted workspaces (no permission prompts)

For trusted repos, containers, or VMs where you want long-running agent tasks
without clicking through Claude Code permission prompts, use:

```bash theme={null}
sail claude --trusted
```

`--trusted` launches Claude Code in bypass-permissions mode. This avoids Claude
Code's auto-mode safety classifier path, so it also avoids failures like
`safety classifier temporarily unavailable` when Sail model requests are
otherwise healthy. Use it only where you are comfortable letting Claude Code run
tools without prompting.

This works inside a [Sailbox](/sailboxes) too: Sail sets `IS_SANDBOX=1` on
Sailbox commands by default, which Claude Code recognizes as a sandbox, so
bypass-permissions mode is allowed there even for root (the default user for
Sailbox commands when the image does not set one). Setting `IS_SANDBOX`
yourself on a command replaces the default for that command. A Sailbox created
before this marker existed gains it after an [upgrade](/sailbox-sdk#upgrade).

Pass flags through to `claude` after `--`:

```bash theme={null}
sail claude -- --resume
```

## VS Code extension

The VS Code extension isn't launched from your shell, so it doesn't receive
per-invocation environment variables. Persist the routing instead:

```bash theme={null}
sail claude on    # writes ~/.claude/settings.json
sail claude off   # removes exactly what `sail claude on` added
```

`sail claude off` removes only the keys `sail claude on` wrote. Settings that
changed while it was on, whether you changed them or Claude Code did, are kept.

Extension sessions read that env block, but the extension's own pre-launch
login check does not. If you don't have a saved Anthropic login, also add
the routing to VS Code's user settings (`Preferences: Open User Settings
(JSON)`) and reload the window. `sail claude on` prints this snippet:

```json theme={null}
"claudeCode.disableLoginPrompt": true,
"claudeCode.environmentVariables": [
  { "name": "ANTHROPIC_BASE_URL", "value": "https://api.sailresearch.com" },
  { "name": "ANTHROPIC_AUTH_TOKEN", "value": "<your SAIL_API_KEY>" }
]
```

Reload the extension after configuring. Use `sail claude on --project` to scope
the routing to one repository. It writes your API key into
`.claude/settings.local.json` (Claude Code's personal, not-shared project
file) and adds that file to `.claude/.gitignore` so it stays out of commits.
Claude Code applies project settings only after you trust the folder in its
first-run prompt.

## Choosing models

GLM-5.3 is the default. The `/model` picker lists five Sail-hosted rows:

| Picker row | Model id | Also selectable with |
| - | - | - |
| GLM-5.3 via Sail (default) | `zai-org/GLM-5.3` | `/model opus` |
| DeepSeek V4 Pro via Sail | `deepseek-ai/DeepSeek-V4-Pro-0813` | `/model sonnet` |
| GLM-5.3-Flash via Sail | `zai-org/GLM-5.3-Flash` | `/model haiku` |
| Kimi K3 via Sail | `moonshotai/Kimi-K3` | `/model fable` |
| DeepSeek V4.1 Flash via Sail | `deepseek-ai/DeepSeek-V4.1-Flash` | `/model <id>` |

You can switch models in these ways:

* **Mid-session:** open `/model` and pick a row, or type `/model <id>` for
  any id in the table. The choice lasts for this session only: Sail pins the
  startup model, so the next launch starts on the configured main model
  again. Use the two options below to persist a different one.
* **At launch:** `--model <id>` starts on that model. Any id from the
  [model catalog](/models) works, not only the five rows. A model outside the
  lineup is added to the picker for that session.
* **Persistently:** `sail claude on --model <id>` pins it for every Claude Code
  that reads your settings.

```bash theme={null}
sail claude --model moonshotai/Kimi-K3
```

GLM-5.3-Flash handles Claude Code's background (haiku-tier) work by default.
`--background-model <id>` changes that. Subagents use the main model either
way.

The table above shows the default rows. The rows are Claude Code's `opus`,
`sonnet`, `haiku`, and `fable` model aliases plus one custom row, and Sail
points each one at a different Sail model. The main model always takes the
`opus` row, which the picker lists first, and the background model takes the
`haiku` row. The remaining Sail models fill the other rows, so no model appears
twice. For example, with `--model moonshotai/Kimi-K3`, Kimi K3 moves to the
first row and GLM-5.3 moves to the `sonnet` row.

`sail claude` and `sail claude on` write Claude Code's `availableModels` setting
so fresh local sessions show only Sail-backed picker rows, with the main model
first so the picker's Default row resolves to it. Claude Code concatenates
non-managed `availableModels` from user, project, local, and temporary settings,
though, so rows from another settings scope may still appear. Rows that name
non-Sail models (such as `claude-*` IDs) still route to Sail and will not be
served there. Remove them from the other settings file or enforce the picker
with managed settings. `sail claude on` prints a warning when it can see those
extra rows.

## Choosing a completion window

Claude Code runs on Sail's default [completion window](/completion-windows),
`asap`, unless you choose another one. Lower-priced windows trade latency for
cost:

```bash theme={null}
sail claude --completion-window balanced
```

* Accepts `asap` or `balanced`.
* Covers every request the session sends: the main model, background work, and
  subagents.
* `sail claude on --completion-window balanced` persists the window for every
  Claude Code that reads your settings, such as a bare `claude` or the VS Code
  extension. Run `sail claude on` without the flag to return to the default.
* `sail claude` sets each session up from its own flags, so a window saved with
  `on` does not carry over. Pass `--completion-window` to `sail claude` as well.
* `balanced` suits long agentic sessions: turns can take longer, at lower token
  prices. See [Pricing](/pricing).
* The `/model` picker lists `asap` prices whichever window you choose.

`flex` is unavailable in Claude Code because its Messages API requests wait for
each turn. Use `balanced` for lower-cost sessions. If an earlier setup saved
`flex`, run `sail claude on --completion-window balanced` to replace it, or
`sail claude off` to remove Sail routing.

The flag sets Claude Code's `ANTHROPIC_CUSTOM_HEADERS` to
`X-Sail-Completion-Window: <window>`, the
[header Sail reads a completion window from](/completion-windows#via-request-header)
when a request body names none.

## Commit attribution

`sail claude on` sets Claude Code's top-level `attribution.commit` to a Sail
co-author trailer naming the resolved model:

```
Co-Authored-By: GLM-5.3 via Sail <noreply@sailresearch.com>
```

Commits and PRs the agent makes are then attributed to the Sail-served model
instead of Anthropic's default model-derived trailer. A `--model` override names
that model in the trailer instead (so a non-default setup isn't misattributed to
GLM-5.3). `attribution.pr` is emptied (no PR-body attribution line). `sail
claude off` puts your original `attribution` back. This only affects the
persisted path: a plain `sail claude` session does not touch attribution.

## Manual configuration

If you'd rather configure Claude Code yourself, set the routing environment by
hand (`sail claude env` prints the full block, including picker display
metadata):

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.sailresearch.com"   # bare host: Claude Code appends /v1/messages
export ANTHROPIC_AUTH_TOKEN="$SAIL_API_KEY"                # bearer auth (recommended); ANTHROPIC_API_KEY also works
export ANTHROPIC_MODEL="zai-org/GLM-5.3"               # pins startup over a saved /model choice
export ANTHROPIC_DEFAULT_OPUS_MODEL="zai-org/GLM-5.3"                    # one Sail model per alias row
export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-ai/DeepSeek-V4-Pro-0813"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="zai-org/GLM-5.3-Flash"             # haiku = background work
export ANTHROPIC_DEFAULT_FABLE_MODEL="moonshotai/Kimi-K3"
export ANTHROPIC_CUSTOM_MODEL_OPTION="deepseek-ai/DeepSeek-V4.1-Flash"
export ANTHROPIC_DEFAULT_OPUS_MODEL_NAME="GLM-5.3 via Sail"              # picker labels; _DESCRIPTION too
export ANTHROPIC_DEFAULT_SONNET_MODEL_NAME="DeepSeek V4 Pro via Sail"
export ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME="GLM-5.3-Flash via Sail"
export ANTHROPIC_DEFAULT_FABLE_MODEL_NAME="Kimi K3 via Sail"
export ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="DeepSeek V4.1 Flash via Sail"
export CLAUDE_CODE_SUBAGENT_MODEL="zai-org/GLM-5.3"     # pins subagents too; overrides frontmatter + any inherited value
export ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES="effort,thinking"                  # custom model IDs match no known
export ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES="effort,thinking,xhigh_effort"   # pattern, so effort + extended
export ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES="effort,thinking"                 # thinking would be silently
export ANTHROPIC_DEFAULT_FABLE_MODEL_SUPPORTED_CAPABILITIES="effort,thinking,xhigh_effort"    # disabled without these
export ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES="effort,thinking,xhigh_effort"
export API_TIMEOUT_MS="3000000"
export API_FORCE_IDLE_TIMEOUT="0"                          # off: else a 5-min stream-idle watchdog (on for custom base URLs) aborts long-queued turns
export ENABLE_TOOL_SEARCH="false"                          # tool search needs tool_reference expansion Sail doesn't serve
# Clear leftovers from other provider setups. Selectors outrank
# ANTHROPIC_AUTH_TOKEN, and stale custom headers would be sent to Sail:
unset CLAUDE_CODE_USE_BEDROCK CLAUDE_CODE_USE_VERTEX CLAUDE_CODE_USE_FOUNDRY \
  CLAUDE_CODE_USE_MANTLE CLAUDE_CODE_USE_ANTHROPIC_AWS ANTHROPIC_CUSTOM_HEADERS
# Optional: choose a completion window (the default is asap).
# export ANTHROPIC_CUSTOM_HEADERS="X-Sail-Completion-Window: balanced"
claude
```

Notes on these settings:

* **Use the bare host.** Claude Code appends `/v1/messages` itself. A `/v1`
  base URL would resolve to `/v1/v1/messages` and return a 404.
* **`ANTHROPIC_AUTH_TOKEN` is what Sail expects.** Sail also accepts
  `ANTHROPIC_API_KEY`, which Claude Code sends through `x-api-key`. Set only
  one credential variable to avoid ambiguous client precedence.
* **Pin `ANTHROPIC_MODEL` and remap every alias.** A saved `/model` choice
  (or a `--resume`d session) can otherwise start on an unmapped `claude-*`
  model ID that Sail cannot serve. Each alias row can point at a different
  Sail model, which is how the five-row picker above is built: Claude Code
  offers four alias rows plus one custom row, and the `_NAME` companions label
  them.
* **Pin `CLAUDE_CODE_SUBAGENT_MODEL`.** It's the highest-priority subagent
  model source, so a value inherited from your shell or a settings file (e.g.
  a `claude-*` ID left over from a prior Anthropic/Bedrock setup) would send
  every subagent to an unmapped model. Setting it to a Sail model routes all
  subagents onto GLM.
* **Declare `_SUPPORTED_CAPABILITIES`.** Claude Code enables effort levels and
  extended thinking by matching the model ID against known patterns. A custom
  ID like `zai-org/GLM-5.3` matches none, so `/effort` and thinking are
  silently disabled without the declaration. Sail maps both onto each model's
  reasoning controls. The DeepSeek and Kimi rows also declare `xhigh_effort`.
* **Unset other providers' variables.** A provider selector such as
  `CLAUDE_CODE_USE_BEDROCK` comes before `ANTHROPIC_AUTH_TOKEN` in Claude
  Code's credential precedence, so a leftover export would silently keep
  routing to that provider instead of Sail. `ANTHROPIC_CUSTOM_HEADERS` from a
  prior gateway setup would be sent to Sail on every request. `sail claude`
  strips these automatically, and sets `ANTHROPIC_CUSTOM_HEADERS` only to the
  Sail completion window header when you pass `--completion-window`. By hand,
  the `unset` line above does the same.

## Limitations

* The native Claude Code **desktop app** reads endpoint routing only from
  managed (administrator-distributed) configuration. It cannot be pointed at
  Sail with environment variables or `settings.json`. Use the terminal or the
  VS Code extension.
* A signed-in **Claude apps gateway** session (an enterprise/corporate-SSO
  deployment) is not part of the normal credential precedence and overrides
  `ANTHROPIC_AUTH_TOKEN`, so `claude` keeps using the gateway and never sends
  requests to Sail. This only affects orgs running that gateway. Ordinary
  Pro/Max users don't have one. If you do, run `/logout` first, or launch that
  session with `CLAUDE_CONFIG_DIR` pointed at an empty directory (note: an
  isolated config dir won't see your normal Claude Code settings/MCP servers).
* An administrator-managed (MDM / policy) `availableModels` allowlist that
  excludes the Sail model takes precedence. Claude Code replaces the model at
  startup (with a warning), and a managed allowlist cannot be overridden
  because managed settings take precedence over the per-session settings
  `sail claude` uses. That's an enterprise policy. Raise it with your admin.
  (If you set `availableModels` yourself in your own `settings.json`, just
  include the Sail model id, e.g. `zai-org/GLM-5.3`, or drop the restriction.)
* Sail is throughput-optimized. Long agentic turns can take longer than the
  Anthropic API. `sail claude` raises Claude Code's request timeout and disables
  its 5-minute stream-idle watchdog (on by default for custom base URLs) so a
  turn that queues before streaming isn't aborted mid-flight.
* Subagents run on the main Sail model by default: `sail claude` pins
  `CLAUDE_CODE_SUBAGENT_MODEL`, which overrides a subagent's frontmatter
  `model:` field. That makes custom subagents with a `claude-*` frontmatter ID
  work (they route to the main model instead of failing), but it also means
  per-subagent model choices and `--background-model` don't apply to
  subagents: they all use the main model. Override it yourself if you need a
  specific Sail model for subagents.
* Background (haiku-tier) work runs on GLM-5.3-Flash by default rather than
  the main model. Pass `--background-model zai-org/GLM-5.3` to keep everything
  on one model.

## Next steps

<CardGroup cols={2}>
  <Card title="Models" href="/models">
    Browse the catalog for alternative models.
  </Card>

  <Card title="Pricing" href="/pricing">
    Per-token rates by model and completion window.
  </Card>

  <Card title="Completion windows" href="/completion-windows">
    How the latency-for-price tradeoff works.
  </Card>

  <Card title="Support matrix" href="/support">
    What the Anthropic-compatible API supports.
  </Card>

  <Card title="AI Quickstart" href="/ai-quickstart">
    Give Claude Code Sail's docs MCP and workflow skills, including
    sail-migrate.
  </Card>

  <Card title="Sail for coding agents" href="/coding-agents">
    Delegate scoped work or request a review from Sail.
  </Card>

  <Card title="Migrate to the Sail API" href="/migrate">
    Move an existing app or agent to Sail.
  </Card>
</CardGroup>
