Back to guides

OpenClaw Integration

Use GPT-5.4, Claude Opus, Gemini, or any model with OpenClaw across Discord, WhatsApp, Telegram, and more. Simple configuration, full cost tracking.

OpenClaw is a self-hosted gateway that connects your favorite chat apps—WhatsApp, Telegram, Discord, iMessage, and more—to AI coding agents. With LLM Gateway as a custom provider, you can route all your OpenClaw traffic through a single API, use any of 180+ models, and keep full visibility into usage and costs.

Quick Start

Add LLM Gateway as a custom provider in your ~/.openclaw/openclaw.json:

1{
2 "models": {
3 "mode": "merge",
4 "providers": {
5 "llmgateway": {
6 "baseUrl": "https://api.llmgateway.io/v1",
7 "apiKey": "${LLMGATEWAY_API_KEY}",
8 "api": "openai-completions",
9 "models": [
10 {
11 "id": "gpt-5.4",
12 "name": "GPT-5.4",
13 "contextWindow": 128000,
14 "maxTokens": 32000
15 },
16 {
17 "id": "claude-opus-4-6",
18 "name": "Claude Opus 4.6",
19 "contextWindow": 200000,
20 "maxTokens": 8192
21 },
22 {
23 "id": "gemini-3-1-pro-preview",
24 "name": "Gemini 3.1 Pro",
25 "contextWindow": 1000000,
26 "maxTokens": 8192
27 }
28 ]
29 }
30 }
31 },
32 "agents": {
33 "defaults": {
34 "model": {
35 "primary": "llmgateway/gpt-5.4"
36 }
37 }
38 }
39}

Then set your API key:

1export LLMGATEWAY_API_KEY=llmgtwy_your_api_key_here

Why Use LLM Gateway with OpenClaw

  • Model flexibility — Switch between GPT-5.4, Claude Opus, Gemini, or any of 180+ models
  • Cost tracking — Monitor exactly how much your chat agents cost to run
  • Single bill — No need to manage multiple API provider accounts
  • Response caching — Repeated queries hit cache, reducing costs
  • Rate limit handling — Automatic fallback between providers

Configuration Options

Switching Models

Change the primary model in your config to switch between any model:

1{
2 "agents": {
3 "defaults": {
4 "model": { "primary": "llmgateway/claude-opus-4-6" }
5 }
6 }
7}

Model Fallback Chain

OpenClaw supports fallback models. If the primary model is unavailable, it automatically falls back:

1{
2 "agents": {
3 "defaults": {
4 "model": {
5 "primary": "llmgateway/gpt-5.4",
6 "fallbacks": ["llmgateway/claude-opus-4-6"]
7 }
8 }
9 }
10}

Available Models

LLM Gateway uses root model IDs with smart routing—automatically selecting the best provider based on uptime, throughput, price, and latency. You can use any model from the models page. Flagship models include:

Model Best For
gpt-5.4 Latest OpenAI flagship, highest quality
claude-opus-4-6 Anthropic's most capable model
claude-sonnet-4-6 Fast reasoning with extended thinking
gemini-3-1-pro-preview Google's latest flagship, 1M context window
o3 Advanced reasoning tasks
gpt-5.4-pro Premium tier with extended reasoning
gemini-2.5-flash Fast responses, good for high-volume
claude-haiku-4-5 Cost-effective, quick responses
grok-3 xAI flagship
deepseek-v3.1 Open-source with vision and tools

For more details on routing behavior, see the routing documentation.

Monitoring Usage

Once configured, all OpenClaw requests appear in your LLM Gateway dashboard:

  • Request logs — See every message and response
  • Cost breakdown — Track spending by model and time period
  • Usage analytics — Understand your AI usage patterns across channels

Tips for Chat Agents

Optimize Costs

  1. Use smaller models for simple tasks — Claude Haiku or Gemini Flash handle basic Q&A well
  2. Enable caching — LLM Gateway caches identical requests automatically
  3. Set token limits — Configure max tokens to prevent runaway costs

Improve Response Quality

  1. Choose the right model — Claude Opus excels at nuanced conversation, GPT-5.4 at general tasks
  2. Use system prompts — Configure your agent's personality and capabilities
  3. Test multiple models — LLM Gateway makes it easy to A/B test different providers

Get Started

  1. Sign up free — no credit card required
  2. Copy your API key from the dashboard
  3. Add LLM Gateway as a custom provider in your OpenClaw config
  4. Start chatting across your connected channels

Questions? Check our docs or join Discord.