Authentication
API-AI accepts both OpenAI-style Bearer and Anthropic-style x-api-key. Pass either, never both.
Header forms
The gateway normalizes either header internally. Use whichever your SDK already emits.
Authorization: Bearer mdf-... # OpenAI-style
x-api-key: mdf-... # Anthropic-styleEnvironment variables
Our examples keep the key in API_AI_KEY. SDK clients, though, auto-read their own native names by default — either export the key under that name, or pass API_AI_KEY explicitly to the constructor. The matrix below shows what each tool reads:
| Client | Key var | Base URL var |
|---|---|---|
| Anthropic Python / Node SDK | ANTHROPIC_API_KEY | ANTHROPIC_BASE_URL |
| OpenAI Python / Node SDK | OPENAI_API_KEY | OPENAI_BASE_URL or OPENAI_API_BASE |
| Claude Code CLI | ANTHROPIC_API_KEY | ANTHROPIC_BASE_URL |
| Cursor | Settings → Models → API key | Settings → Models → Base URL |
| Roo Code | Provider settings: Anthropic | Custom base URL field |
Verifying authentication
Hit /v1/models for a cheap, side-effect-free check:
curl -s https://api-ai.app/v1/models \
-H "x-api-key: $API_AI_KEY" | jq '.data[].id'A successful response lists the current models. A 401 here means the key is malformed, revoked or not yet active.
Where to keep the key
- Environment variables — the default for most use cases.
~/.zshrc/~/.bashrcwithHISTCONTROL=ignorespaceset, so leading-space commands don’t hit shell history.- Secret managers: 1Password CLI, AWS Secrets Manager, Doppler, GCP Secret Manager.
- Per-project
.envfiles — always.gitignored.
Common pitfalls
- Trailing slash.
https://api-ai.app/v1/vshttps://api-ai.app/v1— some SDKs concatenate the path naively. Use the no-trailing-slash form above. - Double Bearer.
Authorization: Bearer Bearer mdf-...happens when a tool already prependsBearerand you re-add it. Strip the prefix in your config. - Anthropic version header. Always include
anthropic-version: 2023-06-01on raw HTTP calls. SDKs add it for you.
Rotating keys
Write to admin@minedom-france.fr from the email address associated with your purchase. Rotation is free and immediate — the old key is revoked the moment the new one is issued. Balance carries across.