Local models

Point a profile at Ollama, LM Studio, vLLM or llama.cpp on localhost. The server must be running, and the model must handle tool calls.

A local model server is an endpoint like any other (the URL, wire format and key sc sends requests to): a URL on localhost, a wire format, and a key. Start the server before you launch. sc probes it, and a refused connection fails the launch. The model id is the server’s own name for the model, the one its /v1/models lists.

  1. Find the model id

    curl -s <url>/v1/models

    The reply lists the ids the server serves. Take <url> from the table below.

  2. Add the endpoint and a profile

    [endpoints.local]
    url = "http://localhost:11434"
    format = "openai-compat"
    key_csv = "local"
    
    [profiles.local]
    opus = { slug = "local/<model-id>" }

    key_csv = "local" is a placeholder. These servers ignore the key unless you turned authentication on, but the gateway refuses an endpoint with no key at all. Leave /v1 off url; the gateway appends /v1/chat/completions.

  3. Check the routing

    sc profiles local

    It prints a row for each of opus, sonnet and haiku with the model that role goes to; a role the profile does not set is marked as inherited.

  4. Launch on it

    sc -u local <project> <agent>
ServerurlNotes
Ollamahttp://localhost:11434Default context is 4,096 tokens; raise it with OLLAMA_CONTEXT_LENGTH.
LM Studiohttp://localhost:1234Start its local server, and set the context length when you load the model.
vLLMhttp://localhost:8000Tool calls need --enable-auto-tool-choice and a --tool-call-parser for your model.
llama.cpp llama-serverhttp://localhost:8080Set the context with -c.
What the model needs
  • Tool calls. Claude Code sends its tools as function definitions and expects the model to call them. A model or server without tool calling can chat, but cannot edit files or run commands.
  • A long context. Claude Code’s system prompt and tool definitions take tens of thousands of tokens before your first message. A server left at a short default context cuts the request.
  • Streaming, which all four servers support.

A model id that contains deepseek, glm, kimi, qwen, minimax or mimo gets that family’s thinking field, as on a hosted endpoint; any other id gets none (the table).

Keep Claude on the main loop

The profile above runs the main loop on your model too. To keep Claude there and send only Claude Code’s background requests and Haiku subagents to the local model, map only haiku and put opus on the anthropic passthrough endpoint (Anthropic and Claude):

[profiles.claude-local]
opus  = { slug = "anthropic/opus" }
haiku = { slug = "local/<model-id>" }

sonnet inherits opus here, so Sonnet requests stay on Claude too.

Use the Anthropic-compatible API

All four servers also serve the Anthropic Messages API at /v1/messages. To use it, set format = "anthropic-messages"; the gateway then forwards Claude Code’s request untranslated, apart from the model id:

[endpoints.local-anthropic]
url = "http://localhost:11434"
format = "anthropic-messages"
key_csv = "local"

The server then has to accept Claude Code’s own request shape, which local servers cover only in part, so start with openai-compat.

My server needs an API key

If you started the server with an API key, such as vLLM’s --api-key or LM Studio’s authentication setting, read it from the environment instead of the placeholder: key_csv = "${LOCAL_LLM_KEY}". The daemon expands it in its own environment (details).

Next: How the gateway routes

View as Markdown