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.

NixAPI Team March 19, 2026 ~5 min read
OpenClaw Third-Party LLM API Integration Guide

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:

  1. Lower costs - Use relay services like NixAPI
  2. Better models - GPT-5, Claude 3.5, Gemini, etc.
  3. Higher controllability - Custom model parameters, context length
  4. Data privacy - Self-hosted service, data doesn’t pass through third parties

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)

ModelModel IDPrice (¥/1M tokens)Use Case
GPT-5gpt-5¥0.625Flagship, best reasoning
GPT-5.4gpt-5.4¥1.25New flagship, balanced
GPT-5 Minigpt-5-mini¥0.125High value daily tasks
Claude 3.5 Sonnetclaude-3-5-sonnet-20241022¥1.5Strong 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:

  1. Check JSON syntax is correct (use JSON Validator)
  2. Ensure environment variables are set
  3. Restart Gateway: openclaw gateway restart
  4. 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


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