Coding agents
Use Libremodel in OpenClaw
OpenClaw is an open-source personal assistant that runs on your computer, uses tools and answers in the chat apps you already use. Add us as a custom provider and it knows the context window and prices of every model.
1. Install OpenClaw
curl -fsSL https://openclaw.ai/install.sh | bashiwr -useb https://openclaw.ai/install.ps1 | iexnpm install -g openclaw@latest --allow-scripts=openclaw
openclaw onboardThe installer starts onboarding. When it asks for a model provider, choose Skip for now: you add us in step 3. If you already use OpenClaw, go to step 2.
2. Set your API key
Create a key in API keys and save it as LIBREMODEL_API_KEY. On macOS and Linux, add the line to ~/.zshrc or ~/.bashrc so every new terminal has it.
export LIBREMODEL_API_KEY="sk-libremodel-..."[Environment]::SetEnvironmentVariable("LIBREMODEL_API_KEY", "sk-libremodel-...", "User")3. Add Libremodel
Add this to OpenClaw's config file (openclaw config file prints its path; by default ~/.openclaw/openclaw.json). The libremodel provider goes under models.providers, next to the ones you have, and agents.defaults.model.primary makes DeepSeek V4.1 Flash the default model. Check the file with openclaw config validate.
{
"agents": {
"defaults": {
"model": {
"primary": "libremodel/deepseek-v4.1-flash-1017"
}
}
},
"models": {
"providers": {
"libremodel": {
"baseUrl": "https://api.libremodel.ai/v1",
"apiKey": "${LIBREMODEL_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "kimi-k3.1-pro-uncensored",
"name": "Kimi K3.1 Pro Uncensored",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 3,
"output": 9,
"cacheRead": 0.3
},
"contextWindow": 1048576,
"maxTokens": 131072,
"compat": {
"supportedReasoningEfforts": [
"low",
"high",
"max"
]
}
},
{
"id": "deepseek-v4.1-flash-1017-uncensored",
"name": "DeepSeek V4.1 Flash Uncensored",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 0.25,
"output": 0.9,
"cacheRead": 0.04
},
"contextWindow": 1048576,
"maxTokens": 131072,
"compat": {
"supportedReasoningEfforts": [
"off",
"low",
"high",
"max"
]
}
},
{
"id": "glm-5.3-flash-uncensored",
"name": "GLM 5.3 Flash Uncensored",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 0.3,
"output": 1.2,
"cacheRead": 0.06
},
"contextWindow": 1048576,
"maxTokens": 131072,
"compat": {
"supportedReasoningEfforts": [
"low",
"high",
"max"
]
}
},
{
"id": "kimi-k3.1-pro",
"name": "Kimi K3.1 Pro",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 1,
"output": 6,
"cacheRead": 0.25
},
"contextWindow": 1048576,
"maxTokens": 131072,
"compat": {
"supportedReasoningEfforts": [
"low",
"high",
"max"
]
}
},
{
"id": "deepseek-v4.1-flash-1017",
"name": "DeepSeek V4.1 Flash",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 0.04,
"output": 0.3,
"cacheRead": 0.004
},
"contextWindow": 1048576,
"maxTokens": 262144,
"compat": {
"supportedReasoningEfforts": [
"off",
"low",
"high",
"max"
]
}
},
{
"id": "minimax-m3.1-flash",
"name": "MiniMax M3.1 Flash",
"reasoning": true,
"input": [
"text",
"image"
],
"cost": {
"input": 0.05,
"output": 0.2,
"cacheRead": 0.005
},
"contextWindow": 1048576,
"maxTokens": 131072,
"compat": {
"supportedReasoningEfforts": [
"low",
"high",
"max"
]
}
}
]
}
}
}
}A Gateway running as a background service does not inherit your terminal's variables. Also save the key in .env, in the same folder as openclaw.json.
LIBREMODEL_API_KEY=sk-libremodel-...4. Start it
Start the Gateway as a background service, check that it is running and open the chat in the terminal. openclaw dashboard opens it in the browser instead.
openclaw gateway install
openclaw gateway start
openclaw gateway status
openclawSwitch models with /model libremodel/<model id> and reasoning effort with /thinking <level>. /status shows the context used and the estimated cost of the session.
Troubleshooting
Run this in the same terminal you start the tool from. It costs nothing. A list of models means the key is fine. A 401 means LIBREMODEL_API_KEY is empty or wrong in that terminal; open a new one after saving it.
curl -s https://api.libremodel.ai/v1/models -H "Authorization: Bearer $LIBREMODEL_API_KEY"curl.exe -s https://api.libremodel.ai/v1/models -H "Authorization: Bearer $env:LIBREMODEL_API_KEY"If the key is fine and the tool gets a 402, your balance does not cover the request. See Billing and credits.
Notes
Agents that run subagents send several requests at once. When capacity is busy, the extra ones wait in a short queue instead of failing. See Limits and errors.
OpenClaw estimates the cost with the prices in its config. What each request is charged is in Activity.