How to use Unlid in Claude Code

Connect Claude Code to Unlid: create an API key, point Claude Code at the base URL below and pick a model id. The same settings work for every Unlid model.

Use Unlid in your apps

Any app that lets you add an OpenAI-compatible provider can use every Unlid model. You always need the same three things:

Base URLhttps://api.unlid.ai/v1
API keyCreate one under Account → API keys. It starts with ul- and is shown once.
ModelAn id from Models, e.g. glm-5.3-flash-uncensored. Most apps fetch the list for you.

Three rules cover almost every setup problem:

  • Enter the base URL with /v1 and without /chat/completions — the app adds that itself. (Janitor AI and goose are the exceptions, below.)
  • When an app asks for the API type, pick OpenAI Compatible / Chat Completions. That is Unlid’s native protocol. The Anthropic (/v1/messages) and OpenAI Responses (/v1/responses) endpoints exist for Claude Code and Codex, which speak nothing else; they are translated to chat completions and cover less.
  • If the app has a context window setting, fill it in from the model page (glm-5.3-flash-uncensored: 262,144 tokens). A default that is too small cuts long chats; one that is too big ends in context_length_exceeded.

Not sure your key works? Run this from the same computer first — it is the fastest way to tell an app problem from a network problem:

curl https://api.unlid.ai/v1/models -H "Authorization: Bearer ul-…"

Claude Code

Claude Code talks to Unlid’s Anthropic-compatible endpoint https://api.unlid.ai/v1/messages. Set these in the shell that starts claude, or in the env block of ~/.claude/settings.json:

export ANTHROPIC_BASE_URL=https://api.unlid.ai
export ANTHROPIC_AUTH_TOKEN=ul-…                    # or ANTHROPIC_API_KEY=ul-… (sent as x-api-key)
export ANTHROPIC_MODEL=glm-5.3-flash-uncensored
export ANTHROPIC_DEFAULT_SONNET_MODEL=glm-5.3-flash-uncensored
export ANTHROPIC_DEFAULT_OPUS_MODEL=glm-5.3-flash-uncensored
export ANTHROPIC_DEFAULT_HAIKU_MODEL=glm-5.3-flash-abliterated          # background tasks (titles, summaries)
export ANTHROPIC_SMALL_FAST_MODEL=glm-5.3-flash-abliterated             # the same, for older Claude Code versions
export CLAUDE_CODE_SUBAGENT_MODEL=glm-5.3-flash-uncensored
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=262144
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude
  • ANTHROPIC_BASE_URL has no /v1: Claude Code adds /v1/messages itself. Use --model glm-5.3-flash-uncensored or /model glm-5.3-flash-uncensored to switch in a session; any id from Models works, but Claude Code is a tool-heavy agent, so pick one with tool calling.
  • With ANTHROPIC_AUTH_TOKEN the key replaces a saved claude.ai login for these requests. With ANTHROPIC_API_KEY Claude Code asks once to approve the key.
  • CLAUDE_CODE_MAX_CONTEXT_TOKENS tells Claude Code the model’s real window (it assumes 200,000 for ids it does not know) so it compacts in time. CLAUDE_CODE_MAX_OUTPUT_TOKENS keeps each request’s reservation small: without it Claude Code asks for 32,000 output tokens per call, and the hold covers all of them until the reply is settled.
  • CLAUDE_CODE_ATTRIBUTION_HEADER=0 drops a per-conversation block Claude Code puts first in the system prompt (Unlid removes it anyway) and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 stops telemetry and update checks to Anthropic.
  • Works: streaming, tool use (Read, Edit, Bash, MCP tools…), images, thinking (shown as thinking blocks on reasoning models), stop sequences. Not available: Anthropic’s server tools — the WebSearch / WebFetch tools fail with a clear error — PDF documents, and prompt-cache markers (the upstream caches on its own where it can). /context counts are estimates.

Something not working? See troubleshooting, or set up another app.