# Morse API for coding agents

Morse's API is OpenAI-compatible: give any OpenAI SDK the base URL, a Morse key, and a model id. Docs: https://trymorse.ai/inference/docs

| What | Value |
| --- | --- |
| Base URL, OpenAI SDKs | `https://inference.trymorse.ai/v1` |
| Base URL, Anthropic SDKs and Claude Code | `https://inference.trymorse.ai` |
| Auth header | `Authorization: Bearer $MORSE_API_KEY`, or `x-api-key` for Anthropic SDKs |
| Key format | `sk_morse_`, then the secret |
| Models | `GET https://inference.trymorse.ai/v1/models`, no key needed |
| OpenAPI spec | https://trymorse.ai/inference/docs/openapi.json |
| Every docs page | https://trymorse.ai/inference/docs/llms.txt, or https://trymorse.ai/inference/llms-full.txt in one file |

## First request

```bash
curl https://inference.trymorse.ai/v1/chat/completions \
  -H "Authorization: Bearer $MORSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "z-ai/glm-5.3-flash",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

## Rules

- Call the API from a server or a backend function. It refuses calls straight from a browser (CORS).
- Read the key from the `MORSE_API_KEY` environment variable. Never put it in code that ships to a browser or a phone.
- Add .md to any docs page's address for its Markdown, such as https://trymorse.ai/inference/docs/authentication.md.

## Errors and fixes

An error is JSON: `{"error": {"message", "type", "param", "code"}}`. Branch on `error.code`. Every code: https://trymorse.ai/inference/docs/api/errors

| Status and code | Fix |
| --- | --- |
| `401 invalid_api_key` | Send `Authorization: Bearer $MORSE_API_KEY` with a live `sk_morse_` key. |
| `402 insufficient_balance` | Add credits at https://console.trymorse.ai. A key pays from them. |
| `403 use_inference_door` | Set the base URL to https://inference.trymorse.ai/v1. The Morse app's address takes no key. |
| `404 model_not_found` | Use an id that GET https://inference.trymorse.ai/v1/models lists. |
| `400 invalid_parameter` | Read `error.message`, which names the parameter at fault. |
| `429 rate_limit_exceeded` | Wait the seconds `Retry-After` names, then retry. |
| A CORS error in a browser | Call the API from your server or a backend function, and keep the key there. |
