Vai al contenuto
Documentazione:Authentication

Per iniziare

Authentication

Every request carries an API key. How keys are created, restricted and revoked, and the errors you get when one is refused.

Questa pagina non è ancora stata tradotta. Viene mostrata la versione inglese.

Send your key in the Authorization header

Every request to https://api.minu.ai must carry an API key as a bearer token:

Shell
curl https://api.minu.ai/v1/balance \
  -H "Authorization: Bearer $MINU_API_KEY"

Keys start with mk_live_. The same key works for the Task API, the OpenAI-compatible endpoints and the kie.ai-compatible routes.

With the official OpenAI SDKs, pass the key as apiKey (Node.js) or api_key (Python); the SDK sends the same header. See OpenAI-compatible API.

Create and manage keys

Keys are created in the console, under API keys, by an owner, an admin or a developer of the organization.

  • The full key is shown once, when you create it. Minu stores only a hash of it and cannot show it again. If you lose a key, create a new one and revoke the old one.
  • A key belongs to an organization. Every key of an organization spends the same balance and counts against the same rate limit.
  • Revoking a key takes effect immediately and cannot be undone.

The console lists each key by its name, its first characters and its last four, together with when it was last used.

Restrict what a key can do

Each restriction is optional. Set them when you create a key, or change them later.

RestrictionWhat it doesWhen a request breaks it
Allowed modelsThe key can use only the models you list. Leave it empty to allow every model.403 model_not_allowed
IP allowlistThe key works only from the addresses or CIDR ranges you list, such as 203.0.113.0/24.403 ip_not_allowed
Daily spend capNew work is refused once the key has spent this many dollars in a day. Days are counted in UTC.402 spend_cap_reached
ExpiryThe key stops working at the time you set.401 key_revoked

A good default for production: one key per service, restricted to the models that service uses, with an IP allowlist if the service has fixed addresses and a daily cap a little above what you expect to spend.

Keep keys safe

  • Call Minu from your server. A key placed in a browser page or a mobile app can be read by anyone who uses it.
  • Keep keys in environment variables or a secret manager, not in source code.
  • Use separate keys for production, staging and each developer, so that one can be revoked without touching the others.
  • Rotate a key by creating the new one, deploying it, and then revoking the old one.

Authentication errors

Errors use the standard error shape.

StatusCodeMeaning
401invalid_api_keyThe Authorization header is missing or malformed, or the key does not exist.
401key_revokedThe key was revoked, or it has expired.
403ip_not_allowedThe request came from an address outside the key's IP allowlist.
403model_not_allowedThe key is not allowed to use the model in the request.
403organization_suspendedThe organization is suspended. Contact support.
402spend_cap_reachedThe key has reached its daily spend cap.
JSON
{
  "error": {
    "code": "invalid_api_key",
    "message": "Send your API key in the Authorization header: \"Authorization: Bearer mk_live_…\"."
  }
}

Console sessions are separate

Signing in to the console (with an e-mailed code) gives you a browser session for managing the organization. It is not an API key and cannot be used to call the API; the API accepts only keys.