Skip to content

Authentication ​

ModelFold uses two independent credential systems:

CallerAPICredentialHeader
Your backend/v1 gatewayAPI key (mf- prefix)Authorization: Bearer mf-...
Console frontend/api/*Session token (JWT)Authorization: Bearer <token>

Model calls require an API key. You do not need a session token.

Call models with an API key ​

Set the Authorization header to Bearer <key>:

bash
curl -X POST "https://modelfold.ai/v1/chat/completions" \
  -H "Authorization: Bearer mf-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"你好"}]}'

Keep API keys out of client code

An API key grants access to your account's model usage. Store it in server-side environment variables. Do not embed keys in browser code, mobile app bundles or public repositories.

Create and revoke keys ​

ActionEndpointBehavior
ListGET /api/keysReturns masked keys, creation times and last-used times
CreatePOST /api/keysAccepts { "name": "..." }; returns the plaintext key
RevokeDELETE /api/keys/:idInvalidates the key immediately
  • Each account can have 10 active keys. Creating another returns 400 too_many_keys.
  • Keys are stored as a hash and an encrypted copy. The list endpoint can recover plaintext for copying, but plaintext keys cannot be found by searching the database.
  • Requests using a revoked key return 401.

Authentication errors ​

HTTPerror.typeCause
401unauthorizedMissing Authorization header, malformed key or revoked key
402insufficient_creditsInsufficient balance; rejected before calling the provider
429rate_limitedGateway rate limit exceeded (60 requests per key per minute by default)

Use a session token with console APIs ​

The /api/auth, /api/account, /api/keys, /api/wallet and /api/mail APIs serve the console. They use the JWT returned by login:

bash
curl -X POST "https://modelfold.ai/api/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","password":"your-password"}'

Tokens are valid for seven days by default. Changing or resetting a password invalidates sessions on other devices immediately while retaining the current device's session after a password change. You can sign out individual devices from the console's session list.

Security recommendations ​

  • Create separate keys for development, staging and production so you can revoke them independently.
  • Review each key's last-used time in the console and revoke keys you no longer use.
  • The gateway records each call's model, endpoint, status, credits and latency. Review these in the console's usage history.

ModelFold — one API for all the best AI models.