# OpenClaw

Use a key from a **GPT group** (see [Groups](https://docs.2api.dev/en/start/endpoints/#groups)). First install OpenClaw by following the [OpenClaw docs](https://docs.openclaw.ai). You can skip the model configuration during installation.

1. Open `~/.openclaw/openclaw.json`, add a `2api` entry under `models.providers`, and point `agents.defaults.model.primary` at it. Keep your other existing settings and merge in only these two sections:

   ```json5 title="~/.openclaw/openclaw.json"
   {
     "models": {
       "providers": {
         "2api": {
           "baseUrl": "https://2api.dev/v1",
           "apiKey": "sk-your-key",
           "api": "openai-responses",
           "models": [
             {
               "id": "model-name",
               "name": "2api GPT",
               "reasoning": true,
               "input": ["text", "image"]
             }
           ]
         }
       }
     },
     "agents": {
       "defaults": {
         "model": { "primary": "2api/model-name" }
       }
     }
   }
   ```

   Replace both `model-name` values with the same name. Look it up with [`/v1/models`](https://docs.2api.dev/en/start/endpoints/#model-names).

2. Save, restart the OpenClaw gateway, and send a message.

:::note[If the api setting gives an error]
`api` is the protocol OpenClaw uses for requests. If `openai-responses` gives an error, try `openai-completions`.
:::

:::caution[The format in older guides no longer works]
Older guides put `provider`, `base_url` and `api_key` flat at the top level of the file. OpenClaw doesn't accept that. Use the nested `models.providers` structure above.
:::