Coding tools
OpenClaw
Add Deference to OpenClaw as a custom model provider in openclaw.json.
OpenClaw reads its config from ~/.openclaw/openclaw.json, a JSON5 file. A custom provider names an API format and a base URL. This guide uses Chat Completions with https://deference.si/v1.
Set up
- Create a key in API keys.
- Add the key to
~/.openclaw/.env. The Gateway runs as a background service, so a variable exported in your shell may not reach it.
DEFERENCE_API_KEY=sk-df-...- Add the provider and the model to
~/.openclaw/openclaw.json.
{
agents: {
defaults: {
model: { primary: "deference/anthropic/claude-sonnet-5.5" },
models: {
"deference/anthropic/claude-sonnet-5.5": { alias: "Sonnet" },
},
},
},
models: {
mode: "merge",
providers: {
deference: {
baseUrl: "https://deference.si/v1",
apiKey: "${DEFERENCE_API_KEY}",
api: "openai-completions",
models: [
{
id: "anthropic/claude-sonnet-5.5",
name: "Claude Sonnet 5.5",
reasoning: false,
input: ["text", "image"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 200000,
maxTokens: 64000,
},
],
},
},
},
}Provider changes apply without a restart. If OpenClaw does not pick them up, run openclaw gateway restart.
Each model needs its own entry in models. An alias under agents.defaults.models does not register a model by itself. cost stays at zero because Activity tracks the real cost.
Verify
- Run
openclaw models list --provider deference. The model you declared is listed. - Run
openclaw models status --probe. It makes a live call and reportsok, or a bucket such asauth,billingortimeout. - Send a message to the agent.
- Open Activity. The request is the top row, with the model you chose.
Pick a model
- A model reference is
provider/model-id. OpenClaw splits on the first slash, sodeference/anthropic/claude-sonnet-5.5is providerdeferenceand modelanthropic/claude-sonnet-5.5. - Pin a model with
openclaw models set deference/anthropic/claude-sonnet-5.5, or/model deference/anthropic/claude-sonnet-5.5in chat. apiisopenai-completions(the default),openai-responsesoranthropic-messages. Foranthropic-messages, setbaseUrltohttps://deference.si: OpenClaw adds/v1. Implicit beta headers are off on a custom host, so setheaders: { "anthropic-beta": "..." }if a model needs them.- Raise
timeoutSecondson the provider for slow models.
Troubleshooting
| You see | Cause | Fix |
|---|---|---|
401 invalid_api_key | The Gateway cannot see DEFERENCE_API_KEY | Put it in ~/.openclaw/.env and restart the Gateway |
| The model is not listed | It has no entry in models, only an alias | Add it under models.providers.deference.models |
| The model does not change | The config was invalid, so OpenClaw kept the last good one | Run openclaw doctor, fix the file, and check again |
404 model_not_found | The id differs from the catalog | Copy the id from the Models page |
402 insufficient_credit | No available credit | Add credit |
402 free_credit_not_eligible | The account has only free credit, and this model or request does not qualify | Use an open-weight text model, set a lower max_tokens, or add credit |
402 key_limit_reached | The key reached the credit limit set on it | Raise the key's limit in API keys, or use another key |