Complete Guide: OpenClaw Integration with Third-Party LLM APIs (with NixAPI)
Detailed guide on how to integrate OpenClaw with third-party LLM APIs, including configuration file and conversational methods. Integrate NixAPI for low-cost GPT-5, Claude access.
Updated March 2026: This guide is based on the latest version of OpenClaw, configuration methods verified and working.
Quick Start
What is OpenClaw?
OpenClaw is a self-hosted gateway that connects your chat applications (WhatsApp, Telegram, Discord, etc.) to AI assistants. It supports:
- Multi-channel gateway: One Gateway serves multiple chat applications
- Multi-agent routing: Different users/scenarios use different models
- Plugin extension: Support for Mattermost and more
- Media support: Image, audio, document processing
Why Integrate Third-Party LLM APIs?
OpenClaw defaults to using Pi agent, but you can integrate your own LLM API to get:
- Lower costs - Use relay services like NixAPI
- Better models - GPT-5, Claude 3.5, Gemini, etc.
- Higher controllability - Custom model parameters, context length
- Data privacy - Self-hosted service, data doesn’t pass through third parties
Integration Method 1: Configuration File (Recommended)
1. Locate the Configuration File
OpenClaw configuration file is located at:
~/.openclaw/openclaw.json
2. Add NixAPI Provider
Add NixAPI configuration in the models.providers section:
{
"models": {
"mode": "merge",
"providers": {
"nixapi": {
"baseUrl": "https://api.nixapi.com/v1",
"apiKey": "${NIXAPI_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "gpt-5",
"name": "GPT-5",
"contextWindow": 200000,
"maxTokens": 8192
},
{
"id": "gpt-5.4",
"name": "GPT-5.4",
"contextWindow": 256000,
"maxTokens": 8192
},
{
"id": "gpt-5-mini",
"name": "GPT-5 Mini",
"contextWindow": 200000,
"maxTokens": 8192
},
{
"id": "claude-3-5-sonnet-20241022",
"name": "Claude 3.5 Sonnet",
"contextWindow": 200000,
"maxTokens": 8192
}
]
}
}
}
}
3. Set Environment Variables
Add API Key in the configuration file:
{
"env": {
"NIXAPI_API_KEY": "nix-your-api-key"
}
}
Or set in terminal:
export NIXAPI_API_KEY="nix-your-api-key"
4. Configure Agent Models
Set default and fallback models in agents.defaults.model:
{
"agents": {
"defaults": {
"model": {
"primary": "nixapi/gpt-5.4",
"fallbacks": [
"nixapi/gpt-5",
"nixapi/gpt-5-mini",
"nixapi/claude-3-5-sonnet-20241022"
]
}
}
}
}
5. Configure Different Models for Different Agents
{
"agents": {
"list": [
{
"id": "main",
"model": "nixapi/gpt-5.4"
},
{
"id": "coding-agent",
"name": "coding-agent",
"model": "nixapi/claude-3-5-sonnet-20241022",
"identity": {
"name": "Coding Assistant",
"emoji": "💻"
}
},
{
"id": "cheap-agent",
"name": "cheap-agent",
"model": "nixapi/gpt-5-mini",
"identity": {
"name": "Budget Assistant",
"emoji": "💰"
}
}
]
}
}
6. Complete Configuration Example
{
"meta": {
"lastTouchedVersion": "2026.3.13",
"lastTouchedAt": "2026-03-19T00:00:00.000Z"
},
"env": {
"NIXAPI_API_KEY": "nix-your-api-key"
},
"models": {
"mode": "merge",
"providers": {
"nixapi": {
"baseUrl": "https://api.nixapi.com/v1",
"apiKey": "${NIXAPI_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "gpt-5",
"name": "GPT-5",
"contextWindow": 200000,
"maxTokens": 8192
},
{
"id": "gpt-5.4",
"name": "GPT-5.4",
"contextWindow": 256000,
"maxTokens": 8192
},
{
"id": "gpt-5-mini",
"name": "GPT-5 Mini",
"contextWindow": 200000,
"maxTokens": 8192
},
{
"id": "claude-3-5-sonnet-20241022",
"name": "Claude 3.5 Sonnet",
"contextWindow": 200000,
"maxTokens": 8192
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "nixapi/gpt-5.4",
"fallbacks": [
"nixapi/gpt-5",
"nixapi/gpt-5-mini"
]
},
"workspace": "/root/.openclaw/workspace",
"maxConcurrent": 4
},
"list": [
{
"id": "main",
"model": "nixapi/gpt-5.4"
}
]
}
}
7. Restart Gateway
After configuration, restart OpenClaw Gateway:
# Restart Gateway
openclaw gateway restart
# Or stop and start again
openclaw gateway stop
openclaw gateway start
Integration Method 2: Conversational Method (Dynamic Configuration)
OpenClaw supports dynamic model configuration through conversation, suitable for temporary switching.
1. Configure Using Commands
Send commands via Telegram or other chat channels:
/model nixapi/gpt-5.4
2. Check Current Model
/status
Response example:
📊 Session Status
Model: nixapi/gpt-5.4
Workspace: /root/.openclaw/workspace
Sessions: 3 active
3. Switch Different Agents
/agent coding-agent
Then subsequent conversations will use the model configured for coding-agent.
NixAPI Pricing Comparison
NixAPI Model Prices (March 2026)
| Model | Model ID | Price (¥/1M tokens) | Use Case |
|---|---|---|---|
| GPT-5 | gpt-5 | ¥0.625 | Flagship, best reasoning |
| GPT-5.4 | gpt-5.4 | ¥1.25 | New flagship, balanced |
| GPT-5 Mini | gpt-5-mini | ¥0.125 | High value daily tasks |
| Claude 3.5 Sonnet | claude-3-5-sonnet-20241022 | ¥1.5 | Strong coding ability |
💡 Pricing Note: Prices above are in RMB. 1 RMB recharge = 1 USD credit. Save approximately 94% compared to OpenAI official pricing!
FAQ
Q1: How to get NixAPI API Key?
A: Visit NixAPI to register, go to Console → API Keys → Create New, copy the key (format: nix-xxxxxxxxxxxx).
Q2: Configuration file changes not taking effect?
A:
- Check JSON syntax is correct (use JSON Validator)
- Ensure environment variables are set
- Restart Gateway:
openclaw gateway restart - Check logs:
openclaw gateway logs
Q3: How to verify configuration is successful?
A: Send /status command to check if the current model is the configured NixAPI model.
Q4: Can I configure multiple API providers simultaneously?
A: Yes. Add multiple providers in models.providers:
{
"models": {
"providers": {
"nixapi": {
"baseUrl": "https://api.nixapi.com/v1",
"apiKey": "${NIXAPI_API_KEY}",
"api": "openai-completions",
"models": [...]
},
"moonshot": {
"baseUrl": "https://api.moonshot.ai/v1",
"apiKey": "${MOONSHOT_API_KEY}",
"api": "openai-completions",
"models": [...]
}
}
}
}
Q5: How to configure different models for different users?
A: Create multiple agents, each with different models:
{
"agents": {
"list": [
{
"id": "vip-agent",
"model": "nixapi/gpt-5.4-pro"
},
{
"id": "standard-agent",
"model": "nixapi/gpt-5"
},
{
"id": "budget-agent",
"model": "nixapi/gpt-5-mini"
}
]
},
"bindings": [
{
"agentId": "vip-agent",
"match": {
"channel": "telegram",
"accountId": "vip_user_bot"
}
},
{
"agentId": "standard-agent",
"match": {
"channel": "telegram",
"accountId": "standard_user_bot"
}
}
]
}
Next Steps
- 👉 Sign Up NixAPI — Free trial, $0.2 credits
- 💰 Pricing — Real-time pricing
- 🔧 API Docs — Complete API reference
- 📖 OpenClaw Official Docs — Complete configuration reference
- 💰 GPT-5 Integration Guide — 5-minute quick start
- 🔧 Model Comparison Review — Choose the best model
About the Author: NixAPI Team specializes in LLM API services, helping 200K+ developers access GPT-5, Claude and other models at low cost.
Try NixAPI Now
Reliable LLM API relay for OpenAI, Claude, Gemini, DeepSeek, Qwen, and Grok with ¥1 = $1 top-up
Sign Up Free