Skip to main content
OpenClaw reaches LaoZhang API through two custom providers: openai-completions for GPT, and anthropic-messages for Claude, DeepSeek, and GLM.

Install OpenClaw

OpenClaw needs Node.js >=24.16.0 <25 or >=26.1.0. Node 26 is recommended; Node 24 releases before 24.16.0 are not supported. The install script sets up Node for you if it’s missing, then starts the onboarding wizard:
To install without starting the wizard, run curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard instead. If you’d rather manage Node yourself, install with npm and run the wizard, which also installs the background gateway:
With npm 11.15 or earlier, drop --allow-scripts=openclaw. On macOS you can also use the desktop app from the OpenClaw releases page.

Connect with the wizard

1

Create a LaoZhang API token

In Tokens, create tokens with the Usage first billing mode, one per request format you’ll use:
  • default group for the OpenAI format (GPT).
  • Claude Code group for the Anthropic format (Claude, DeepSeek, and GLM).
Copy the keys and export them in your shell:
If you only use GPT, the first key is enough.
2

Run the wizard and pick Custom provider

Run openclaw onboard, choose Quick start or Custom setup, and select Custom provider when asked for a model provider. Then choose the compatibility type and enter the base URL:
  • OpenAI compatible: https://api.laozhang.ai/v1
  • Anthropic compatible: https://api.laozhang.ai
Paste the matching key when prompted: the default-group key for OpenAI compatible, or the Claude Code-group key for Anthropic compatible. To change these answers later, run openclaw configure.
3

Or run it non-interactively

The same setup in one command, reading the key from the environment:
Without --custom-model-id, OpenClaw reads every model from /v1/models on LaoZhang API. For Claude, DeepSeek, or GLM, use the Anthropic format instead with your Claude Code-group key. It requires a model ID:
4

Set the default model and check it

openclaw models status should show laozhang/gpt-6.1-sol as the default.
5

Run a test turn

Run one agent turn from the terminal. The prompt asks the model to use a tool, so a correct answer shows that chat and tool calls both work:
  • --local runs a single turn with the credentials in your config.
  • --model overrides the model for this run only.
  • --session-id <name> starts a fresh session if you want a clean history.
The request then appears in your call logs. To chat in the browser instead, run openclaw dashboard (optional).

Configure GPT, Claude, DeepSeek, and GLM in openclaw.json

To use all four side by side, define both providers in ~/.openclaw/openclaw.json. The file is JSON5, so comments and trailing commas are allowed. Run openclaw config file if you’re not sure which file your install reads. Each provider reads its own key:
  • laozhang (OpenAI format): LAOZHANG_API_KEY, the default-group key
  • laozhang-anthropic (Anthropic format): LAOZHANG_CLAUDE_API_KEY, the Claude Code-group key
Run openclaw config validate after editing. What each part does:
  • api: openai-completions sends Chat Completions requests and is the default when a provider has a base URL but no api.
  • anthropic-messages: sends Messages requests and adds the Anthropic auth and version headers itself, so you don’t set any headers.
  • baseUrl: include /v1 for the OpenAI format. For the Anthropic format, use the bare host, as in OpenClaw’s own docs.
  • input: models accept text only unless you list "image". Add it only for models that take images.
  • contextWindow: OpenClaw assumes 200,000 tokens when it’s missing and uses this value to decide when to compact. Set it to the actual context window from the model vendor’s documentation.
  • maxTokens: Claude models on LaoZhang API return at most 32,768 output tokens per response, so keep Claude at or below that. See Claude model limits.
  • compat.supportsUsageInStreaming: OpenClaw doesn’t request token usage in streamed responses from custom OpenAI-format hosts unless you turn this on. LaoZhang API returns usage in streams, and with real counts compaction stops relying on estimates.

Keep the key out of the file

Each ${...} reference is replaced with its environment variable when OpenClaw loads the config. The gateway runs as a background service, so it may not see variables exported only in your shell profile. In that case, define both variables in the config’s env.vars block and keep the references in apiKey:
That block holds your full keys, so keep the file out of repositories and screenshots.

Switch models

Changes to models.providers, agents.defaults.models, and the model selection reload automatically, with no gateway restart. To switch models:
  • Default for new sessions: openclaw models set laozhang-anthropic/claude-sonnet-5-5, or edit agents.defaults.model.primary
  • Current chat only: send /model laozhang-anthropic/deepseek-v4-pro
  • See what’s configured: openclaw models list --provider laozhang-anthropic
Model references always take the form provider/model-id.

Request fields for OpenAI-format models

For custom OpenAI-format hosts, OpenClaw sends max_completion_tokens and, for models with reasoning: true, reasoning_effort. LaoZhang API accepts both for gpt-6.1-sol. Since November 4, 2026, GPT-6 and GPT-5.6 models also call tools while reasoning, so you don’t need to turn reasoning off for agent work. If a model you add rejects one of these fields, adjust it in that model’s compat block:
  • maxTokensField changes which field carries the output limit
  • supportsReasoningEffort: false stops OpenClaw from sending reasoning_effort

Choose a model

All four call tools in OpenClaw agent turns. Other Claude IDs are claude-opus-5-5 and claude-haiku-5-5. Prices are in the model catalog.

FAQ

”Auto-compaction could not recover this turn”

OpenClaw tried to compact the conversation and it still didn’t fit the model’s context. Work through these in order:
  1. Retry the message once.
  2. Send /compact to compact the session manually.
  3. Send /new to start a fresh session.
  4. Switch to a model with a larger context window.
To keep it from happening again, set contextWindow to the model’s real value and turn on compat.supportsUsageInStreaming for OpenAI-format models, so OpenClaw works from actual token counts instead of estimates.

Should I still set reserveTokensFloor?

No. These keys under agents.defaults.compaction are retired:
  • reserveTokens
  • reserveTokensFloor
  • maxHistoryShare
Run openclaw doctor --fix to remove them from your config, then let compaction work from an accurate contextWindow for each model.

What does openclaw doctor do?

openclaw doctor checks your install and config and reports problems. Useful options:
  • --fix applies the repairs it can, such as removing retired compaction keys
  • --deep runs a more thorough check
  • --json prints the report as JSON
  • --generate-gateway-token creates a new gateway token
Run openclaw config validate for a quick check of the config file alone.

Port 18789 is already in use (EADDRINUSE)

Another process is already listening on the gateway port, often a gateway you installed earlier as a background service. Run openclaw gateway status to see whether it’s running. If it is, use that gateway instead of starting a second one.

I get AUTH_TOKEN_MISMATCH

The gateway and the client are reading different configs. This usually happens when you edited another copy, for example one selected by --profile or the OPENCLAW_STATE_DIR variable. Run openclaw config file in the same environment the gateway runs in, and make your changes in that file.

Do I need to restart after editing openclaw.json?

No, not for providers or models. Changes to models.providers, agents.defaults.models, and the selected model reload automatically.

Claude keeps thinking after I set reasoning: false

reasoning: false on the model doesn’t turn off Claude’s adaptive thinking. Send /think off in the chat, or set thinkingDefault in your config to turn it off by default.

I get 401, 403, 404, or 503 errors

  • 401: the key is wrong or wasn’t copied in full. Check that both LAOZHANG_API_KEY and LAOZHANG_CLAUDE_API_KEY are set where the gateway runs.
  • 403 or 503 “no available channels”: the token’s group doesn’t include the model, or the model ID is misspelled. Check that laozhang uses a default-group key and laozhang-anthropic a Claude Code-group key. See Check model availability.
  • 404: /v1 is missing from the OpenAI-format baseUrl or appears twice.
  • Insufficient balance: see Insufficient balance.