Authentication
Every request carries your Midium API key. Where to find it, how to send it, and which headers each route accepts.
For developers
Every API request needs your Midium key. A new install makes one for you, so there's nothing to set up: copy it and send it with each request.
Get your key#
- Settings → API — the Your local key box, with a copy button.
- The connection pill at the top of the window — it shows the base URL and key.
- The menu-bar icon — Copy API Key.
- The terminal:
midium key # masked
midium key --reveal # the full key
midium key --bare # only the key, nothing else (for scripts)
--bare is for programs that read a key from a command, for example export OPENAI_API_KEY=$(midium key --bare).
The key looks like sk-midium-local- followed by 32 hex characters. A key from an older install that starts with sk-courier-local- keeps working. It's stored as MIDIUM_API_KEY in ~/Midium/.env.
The key is the only thing that guards your models, vaults and files on this Mac. Don't paste it into shared documents or commit it to a repository.
Send it#
Send the key in the Authorization header. The Bearer prefix is optional on every route:
curl http://127.0.0.1:9100/v1/models -H "Authorization: Bearer YOUR_API_KEY"
curl http://127.0.0.1:9100/v1/models -H "Authorization: YOUR_API_KEY"
OpenAI and Anthropic SDKs send it the right way when you pass the key as api_key.
| Routes | Headers accepted |
|---|---|
/v1/chat/completions, /v1/embeddings, /v1/rerank, /v1/audio/*, /v1/models, model management | Authorization: Bearer <key> or Authorization: <key> |
/v1/messages, /v1/messages/count_tokens | x-api-key: <key> (what Anthropic SDKs send), or Authorization as above |
Admin routes (for example /add-library-model/, /delete-model-files/, /import-local-models/) | Authorization as above, or X-API-Key: <key> |
MCP servers (/v1/code/mcp, /v1/vault/mcp, /mcp) | Authorization as above, or an api_key query parameter for clients that can't set headers |
On a Free, Hub or Member install, your local key is also the admin key for this Mac, so it works on admin routes.
anthropic-version and anthropic-beta headers are accepted on /v1/messages and ignored.
Where requests can come from#
The engine listens on 127.0.0.1:9100, so only programs on this Mac can reach it. UCE_PORT in ~/Midium/.env changes the port. To use the API from another computer, use an SSH tunnel (midium tunnel prints the command) — see Remote access.
Errors#
| Status | Body | Cause |
|---|---|---|
401 | {"detail": "Missing API key"} | No Authorization header. |
401 | {"detail": "API key does not exist"} | The key isn't one this Mac knows. Copy it again from Settings → API. |
403 | {"detail": "Account suspended"} | The key's account is turned off. |
401 | {"type": "error", "error": {"type": "authentication_error", ...}} | The same problems on /v1/messages, in Anthropic's error shape. |
See Errors & limits for every error shape.
Something here wrong or out of date? Tell us.
