# OpenClaw

Connect the OpenClaw agent to eWest.

OpenClaw connects to eWest as a custom OpenAI-compatible provider (`/v1/chat/completions`).

> We haven't tested this setup ourselves; it follows the tool's own documentation. If something doesn't work, contact support.

## Setup

Add an `ewest` provider under `models.providers` in `~/.openclaw/openclaw.json` with `api: "openai-completions"` and base URL `https://api.ewest.ai/v1`. `"${EWEST_KEY}"` reads the key from your environment. List each model you want in `models`, with its context window from [Models](https://ewest.ai/docs/models).

~/.openclaw/openclaw.json:

```json
{
  "models": {
    "mode": "merge",
    "providers": {
      "ewest": {
        "baseUrl": "https://api.ewest.ai/v1",
        "apiKey": "${EWEST_KEY}",
        "api": "openai-completions",
        "models": [
          { "id": "ewest/claude-sonnet", "name": "Claude Sonnet (eWest)", "contextWindow": 1000000 },
          { "id": "ewest/claude-haiku", "name": "Claude Haiku (eWest)", "contextWindow": 200000 },
          { "id": "ewest/gemini-flash", "name": "Gemini Flash (eWest)", "contextWindow": 1048576 }
        ]
      }
    }
  },
  "agents": {
    "defaults": { "model": { "primary": "ewest/ewest/claude-sonnet" } }
  }
}
```

## Choose a model

OpenClaw names models `<provider>/<model id>`. With the provider called `ewest`, that is the provider name followed by the full eWest id: `ewest/ewest/claude-haiku`. Set the default in `agents.defaults.model.primary`, or with `openclaw models set`.

Shell:

```bash
# Refs are <provider>/<model id>, so eWest models get a double prefix.
openclaw models list
openclaw models set ewest/ewest/claude-haiku
```

## Verify it works

`openclaw models list` should show the eWest models. Send a message, then find it in the console under Requests. The cURL request below is what OpenClaw sends, without OpenClaw.

Every response has an `x-request-id` header; paste it into the console under Requests to see the request ([trace IDs](https://ewest.ai/docs/traces)).

cURL:

```bash
# The request OpenClaw sends, without OpenClaw:
curl https://api.ewest.ai/v1/chat/completions \
  -H "Authorization: Bearer $EWEST_KEY" \
  -H "content-type: application/json" \
  -d '{"model": "ewest/claude-haiku", "stream": true, "messages": [{"role": "user", "content": "Reply with the single word OK"}]}'
```

## Streaming and tools

OpenClaw streams and calls tools over `/v1/chat/completions`; there is nothing to set. Use models that support tools: any `ewest/claude-*` model or `ewest/gemini-flash`.

## Troubleshooting

- Unknown model: the ref needs both parts, `ewest/` (the provider) and the full id (`ewest/claude-haiku`), and the id must be listed under the provider's `models`.
- `401`: the key is missing, mistyped or revoked. Copy it again from [API keys](https://ewest.ai/keys).
- `404` with `model_not_found`: the model name needs the `ewest/` prefix (`ewest/claude-haiku`, not `claude-haiku`) and must be in [Models](https://ewest.ai/docs/models).
- `403`: your key is not allowed to use that model; `402`: the key's budget is used up. See [Errors](https://ewest.ai/docs/errors).

cURL:

```bash
# The models your key may call (use these ids exactly, with the ewest/ prefix):
curl -H "Authorization: Bearer $EWEST_KEY" https://api.ewest.ai/v1/models

# One model, with its context window and whether it supports tools and images:
curl -H "Authorization: Bearer $EWEST_KEY" https://api.ewest.ai/v1/models/ewest/claude-haiku
```

Still stuck? Follow [Troubleshoot a request](https://ewest.ai/docs/troubleshooting).

Source: https://ewest.ai/docs/guides/openclaw
