Get your API key

Personal AI agent · setup guide

Connect OpenClaw to AllModelAPI

A self-hosted personal AI agent that can talk to you through chat apps and use tools on your computer. Use AllModelAPI models as its brain.

About 15 minutesWindows · macOS · LinuxUses the Chat Completions APIChecked 19 November 2026
1 · Your computer
Stays in this browser tab. It is never saved or sent anywhere. No key yet? Create one.

Pick the easy way

Easiest

Let an AI agent do it

Already use an AI coding agent (any one: Codex, OpenCode, Cursor, another assistant)? Copy this prompt, paste it into that agent and press Enter. It installs OpenClaw, writes the settings, saves your key and tests everything. It will ask you for your API key.

See what the prompt says
# Task: connect OpenClaw to AllModelAPI

You are a coding agent on my computer. Set up **OpenClaw** so it uses **AllModelAPI** as its model provider. Work step by step, tell me briefly what you are doing, and ask me before doing anything not listed here.

## Facts
- Service: AllModelAPI, an API gateway for DeepSeek, Qwen, GLM, Kimi and MiniMax models.
- OpenClaw talks to it with the Chat Completions API.
- Base URL: `https://api.allmodelapi.com/v1`
- Main model: `deepseek-v4-pro` (DeepSeek V4 Pro, 1000K context). Fast background model: `deepseek-flash`.
- Model IDs are case-sensitive. Full list: https://api.allmodelapi.com/v1/models
- API key: not included. **Ask me to paste my AllModelAPI API key** (I can create one at https://allmodelapi.com/customer/api-keys).
- Human guide: https://allmodelapi.com/documentation/openclaw

## Steps
1. Detect my operating system (macOS, Linux or Windows) and shell.
2. Check whether OpenClaw is installed: `openclaw --version`. If it is not, install it with the official command:
   - macOS: `curl -fsSL https://openclaw.ai/install.sh | bash`
   - Linux: `curl -fsSL https://openclaw.ai/install.sh | bash`
   - Windows (PowerShell): `iwr -useb https://openclaw.ai/install.ps1 | iex`
3. Settings file location:
   - macOS / Linux: `~/.openclaw/openclaw.json`
   - Windows: `%USERPROFILE%\.openclaw\openclaw.json`
4. If the file exists, copy it to `<file>.bak` first. If it contains other settings, **merge**: keep everything unrelated and only add or replace the keys shown below. If it does not exist, create it with exactly this content:

```json
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "allmodelapi/deepseek-v4-pro"
      }
    }
  },
  "models": {
    "mode": "merge",
    "providers": {
      "allmodelapi": {
        "baseUrl": "https://api.allmodelapi.com/v1",
        "apiKey": "${ALLMODELAPI_API_KEY}",
        "api": "openai-completions",
        "models": [
          {
            "id": "deepseek-v4-pro",
            "name": "DeepSeek V4 Pro",
            "contextWindow": 1000000,
            "maxTokens": 131072
          },
          {
            "id": "qwen4-max",
            "name": "Qwen 4 Max",
            "contextWindow": 991808,
            "maxTokens": 131072
          },
          {
            "id": "glm-5.3",
            "name": "GLM 5.3",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "kimi-k3.1-pro",
            "name": "Kimi K3.1 Pro",
            "contextWindow": 1048576,
            "maxTokens": 131072
          },
          {
            "id": "deepseek-flash",
            "name": "DeepSeek V4.1 Flash",
            "contextWindow": 1000000,
            "maxTokens": 131072
          },
          {
            "id": "qwen3.7-plus",
            "name": "Qwen 3.7 Plus",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "qwen3.8-flash",
            "name": "Qwen 3.8 Flash",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "glm-5.3-flash",
            "name": "GLM 5.3 Flash",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "kimi-k3",
            "name": "Kimi K3",
            "contextWindow": 1048576,
            "maxTokens": 131072
          },
          {
            "id": "MiniMax-M3.1-Flash",
            "name": "MiniMax M3.1 Flash",
            "contextWindow": 1000000,
            "maxTokens": 131072
          }
        ]
      }
    }
  }
}
```
5. API key: Add the line `ALLMODELAPI_API_KEY=<key>` to `~/.openclaw/.env` (`%USERPROFILE%\.openclaw\.env` on Windows). Replace an existing ALLMODELAPI_API_KEY line instead of adding a second one.
6. Verify. Run:
```
openclaw doctor
openclaw models list --provider allmodelapi
openclaw agent --local --model allmodelapi/deepseek-v4-pro --message "Reply with just: OK"
```
   A short reply such as "OK" means it works. On 401 re-check the key; on 400 "unknown model" re-check the model ID; on 402 I need more credit.
7. Report: what you changed, where the backup is, and how I start OpenClaw.

## Rules
- Only touch the files named above. Do not remove other providers, models or settings.
- Never print my full API key in your replies or logs, and never put it in a git repository or project file.
- Use JSON that parses: no comments in JSON, no trailing commas.
One paste

Do it in your terminal

Install OpenClaw (step 3 below), save your key (step 4), then paste this one command into PowerShell. It backs up your old settings and writes the complete new file.

Or edit the file yourself: open %USERPROFILE%\.openclaw\openclaw.json, delete everything inside, paste the full file, and save.

No key pasted above, so copied text contains PASTE_YOUR_ALLMODELAPI_KEY_HERE. Paste your key at the top first, or replace that text later.

Step by step, for Windows

Never used a terminal before? That's fine. Follow each step in order. Every grey “Why?” box explains what you just did.

  1. Get your AllModelAPI API key

    Sign in, open API Keys and create a key. Copy it and keep it private: anyone with the key can spend your credit. You will see it only once.

    Why? An API key is like a password for apps. It lets a tool use AI models on your account, and your usage is billed to it.

    Create your key here: https://allmodelapi.com/customer/api-keys

  2. Open a terminal

    Press the Windows key, type PowerShell and press Enter. A blue or black window opens. That is your terminal. Use PowerShell, not Command Prompt.

    Why? A terminal is a window where you type commands instead of clicking buttons. Every command on this page is pasted there.

    To paste in a terminal: Ctrl + V in PowerShell, Cmd + V on Mac, Ctrl + Shift + V on Linux. Then press Enter.

  3. Install OpenClaw

    Paste this command and press Enter. Wait until it finishes. Then close the terminal and open a new one so it can find OpenClaw.

    Why? This downloads the tool from its official website and adds it to your computer.

    Install (PowerShell)
    iwr -useb https://openclaw.ai/install.ps1 | iex
    Check it installed: this should print a version number
    openclaw --version

    Already installed? Skip to the next step.

  4. Save your API key in OpenClaw's .env file

    This adds one line to (Join-Path $HOME ".openclaw\.env"). Replace PASTE_YOUR_ALLMODELAPI_KEY_HERE with your key first, or paste your key in the box at the top of this page.

    Why? OpenClaw reads secrets from its own .env file. That works even when OpenClaw runs in the background, where normal terminal settings are not visible.

    Add the key (PowerShell)
    $env_file = (Join-Path $HOME ".openclaw\.env")
    New-Item -ItemType Directory -Force -Path (Split-Path $env_file) | Out-Null
    Add-Content -Path $env_file -Value "ALLMODELAPI_API_KEY=PASTE_YOUR_ALLMODELAPI_KEY_HERE"

    If you run this twice, open the file and delete the older line so only one key remains.

  5. Save the OpenClaw settings file

    Paste this one command and press Enter. It creates the folder if needed, keeps a backup of any old file (.bak), and writes the complete settings file. Prefer doing it by hand? Use "Copy full config file" at the top, open the file in a text editor, select everything, paste, and save.

    Why? OpenClaw reads its settings from %USERPROFILE%\.openclaw\openclaw.json. This file tells it to send requests to AllModelAPI and which model to use.

    Write the settings file
    $file = Join-Path $HOME ".openclaw\openclaw.json"
    New-Item -ItemType Directory -Force -Path (Join-Path $HOME ".openclaw") | Out-Null
    if (Test-Path $file) { Copy-Item $file "$file.bak" -Force; Write-Host "Backup saved: $file.bak" }
    [System.IO.File]::WriteAllText($file, @'
    {
      "agents": {
        "defaults": {
          "model": {
            "primary": "allmodelapi/deepseek-v4-pro"
          }
        }
      },
      "models": {
        "mode": "merge",
        "providers": {
          "allmodelapi": {
            "baseUrl": "https://api.allmodelapi.com/v1",
            "apiKey": "${ALLMODELAPI_API_KEY}",
            "api": "openai-completions",
            "models": [
              {
                "id": "deepseek-v4-pro",
                "name": "DeepSeek V4 Pro",
                "contextWindow": 1000000,
                "maxTokens": 131072
              },
              {
                "id": "qwen4-max",
                "name": "Qwen 4 Max",
                "contextWindow": 991808,
                "maxTokens": 131072
              },
              {
                "id": "glm-5.3",
                "name": "GLM 5.3",
                "contextWindow": 1000000,
                "maxTokens": 128000
              },
              {
                "id": "kimi-k3.1-pro",
                "name": "Kimi K3.1 Pro",
                "contextWindow": 1048576,
                "maxTokens": 131072
              },
              {
                "id": "deepseek-flash",
                "name": "DeepSeek V4.1 Flash",
                "contextWindow": 1000000,
                "maxTokens": 131072
              },
              {
                "id": "qwen3.7-plus",
                "name": "Qwen 3.7 Plus",
                "contextWindow": 1000000,
                "maxTokens": 128000
              },
              {
                "id": "qwen3.8-flash",
                "name": "Qwen 3.8 Flash",
                "contextWindow": 1000000,
                "maxTokens": 128000
              },
              {
                "id": "glm-5.3-flash",
                "name": "GLM 5.3 Flash",
                "contextWindow": 1000000,
                "maxTokens": 128000
              },
              {
                "id": "kimi-k3",
                "name": "Kimi K3",
                "contextWindow": 1048576,
                "maxTokens": 131072
              },
              {
                "id": "MiniMax-M3.1-Flash",
                "name": "MiniMax M3.1 Flash",
                "contextWindow": 1000000,
                "maxTokens": 131072
              }
            ]
          }
        }
      }
    }
    '@)
    Write-Host "Saved: $file"

    Your old file had other settings you care about? Use the agent prompt instead. It merges instead of replacing.

  6. Restart the OpenClaw background service

    Run this once after saving the files.

    Why? OpenClaw runs a background service (the Gateway). It reads the new settings when it restarts.

    Restart
    openclaw gateway restart
  7. Check that it works

    You should see a short reply such as OK. If you see an error instead, look it up in "Something went wrong?" below.

    Why? This sends one tiny request, so you know the key, the address and the model are all correct before you start a real project.

    Check the setup
    openclaw doctor
    openclaw models list --provider allmodelapi
    Ask one question
    openclaw agent --local --model allmodelapi/deepseek-v4-pro --message "Reply with just: OK"
    Test your key directly (PowerShell)
    Invoke-RestMethod -Method Post -Uri "https://api.allmodelapi.com/v1/chat/completions" `
      -Headers @{ Authorization = "Bearer $env:ALLMODELAPI_API_KEY" } `
      -ContentType "application/json" `
      -Body '{"model":"deepseek-v4-pro","max_tokens":20,"messages":[{"role":"user","content":"Reply with just: OK"}]}'
  8. Start building

    OpenClaw now uses your AllModelAPI model by default. Change it any time with: openclaw models set allmodelapi/<model-id>

The complete settings file

This is the whole file. Every line matters, so copy it with the button instead of selecting it by hand.

%USERPROFILE%\.openclaw\openclaw.json
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "allmodelapi/deepseek-v4-pro"
      }
    }
  },
  "models": {
    "mode": "merge",
    "providers": {
      "allmodelapi": {
        "baseUrl": "https://api.allmodelapi.com/v1",
        "apiKey": "${ALLMODELAPI_API_KEY}",
        "api": "openai-completions",
        "models": [
          {
            "id": "deepseek-v4-pro",
            "name": "DeepSeek V4 Pro",
            "contextWindow": 1000000,
            "maxTokens": 131072
          },
          {
            "id": "qwen4-max",
            "name": "Qwen 4 Max",
            "contextWindow": 991808,
            "maxTokens": 131072
          },
          {
            "id": "glm-5.3",
            "name": "GLM 5.3",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "kimi-k3.1-pro",
            "name": "Kimi K3.1 Pro",
            "contextWindow": 1048576,
            "maxTokens": 131072
          },
          {
            "id": "deepseek-flash",
            "name": "DeepSeek V4.1 Flash",
            "contextWindow": 1000000,
            "maxTokens": 131072
          },
          {
            "id": "qwen3.7-plus",
            "name": "Qwen 3.7 Plus",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "qwen3.8-flash",
            "name": "Qwen 3.8 Flash",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "glm-5.3-flash",
            "name": "GLM 5.3 Flash",
            "contextWindow": 1000000,
            "maxTokens": 128000
          },
          {
            "id": "kimi-k3",
            "name": "Kimi K3",
            "contextWindow": 1048576,
            "maxTokens": 131072
          },
          {
            "id": "MiniMax-M3.1-Flash",
            "name": "MiniMax M3.1 Flash",
            "contextWindow": 1000000,
            "maxTokens": 131072
          }
        ]
      }
    }
  }
}

Something went wrong?

I already connected WhatsApp/Telegram and other settings

The full file replaces your old settings (a .bak backup is saved). To keep them, use the Copy agent prompt button instead: the agent merges only the model part into your file.

401 from the background service

The background service does not see keys saved in your terminal. Keep the key in ~/.openclaw/.env as shown, then restart the service.

Model not recognized

The model ID after allmodelapi/ must be in the models list of the file. Copy the full file again.

401 / invalid API key

The key is missing, mistyped or revoked. Copy it again from https://allmodelapi.com/customer/api-keys and save it again. Keys start with the same prefix you see in your dashboard.

402 / insufficient credit

Your plan credit and pay-as-you-go credit are used up for this request. Add credit or pick a coding plan in Billing, or choose a cheaper model.

400 / unknown model

Model IDs are case-sensitive and must match the AllModelAPI list exactly, for example MiniMax-M3.1-Flash, not minimax-m3.1-flash.

command not found / is not recognized

The tool is not installed, or your terminal was opened before the install finished. Close the terminal, open a new one and try again.

Still stuck? Copy the agent prompt above into any AI assistant and paste the exact error message after it, or write to support@allmodelapi.com. See all models and IDs in the model list.

OpenClaw is a product of the OpenClaw project. AllModelAPI is an independent service and is not affiliated with or endorsed by the OpenClaw project. The guide only shows how to point the tool at AllModelAPI.

Sources we checked on 19 November 2026. Tools change often; if a step looks different on your screen, follow the official page.