Skip to content
Docs menu

Authentication and keys

Keys, headers, test keys and what the status codes mean.

Every request except /health needs your API key. The SDKs send it for you. With HTTP, send it in either header; they are equivalent.

from falcore import Catalyst

catalyst = Catalyst("fal_live_...")   # sent as Authorization: Bearer for you
Warning

Keep the key secret and send it only over HTTPS. Never put it in a URL or in code that other people can read, such as a web page. If it leaks, ask your administrator to revoke it and issue a new one. For a browser, mint a short-lived token on your server instead (see Everything else on the client).

What a missing or wrong key returns

Try it with no key at all. This is safe: nothing is charged and no key is involved.

Shell
curl -sS -i "https://api.falcorelabs.com/v1/fetch/s1"
Output
HTTP/2 401
content-type: application/json
x-request-id: req_f3b387264e7d489d9a3d

{"success":false,"request_id":"req_f3b387264e7d489d9a3d","service":"gateway","session_id":null,"status":"failed","data":null,"files":[],"usage":{"plumes":0},"error":{"code":"UNAUTHORIZED","message":"Send your API key as 'Authorization: Bearer <key>' or the X-API-Key header.","retryable":false}}

(Other headers are left out here. The request id differs on every call.) A key that is sent but is wrong, revoked or unknown answers with a different message:

Shell
curl -sS "https://api.falcorelabs.com/v1/fetch/s1" -H "Authorization: Bearer fal_test_this_key_is_not_real_0000"
Output
{"success":false,"request_id":"req_c1f2d4a51c8f485e84a0","service":"gateway","session_id":null,"status":"failed","data":null,"files":[],"usage":{"plumes":0},"error":{"code":"UNAUTHORIZED","message":"Invalid or revoked API key.","retryable":false}}

An SDK turns that answer into an AuthenticationError. This is what each prints for print(e.status, e.code) and the message:

from falcore import Catalyst, AuthenticationError

try:
    Catalyst("fal_test_this_key_is_not_real_0000").usage.get()
except AuthenticationError as e:
    print(e.status, e.code)
    print(e)
401 UNAUTHORIZED
401 UNAUTHORIZED Invalid or revoked API key. (request req_69a2fa6540cb41cd9b35)
Note

Python and Rust include the request id in the printed error; TypeScript keeps it in e.requestId. The request id differs on every call.

Key types

KeyStarts withBehaviour
Livefal_live_Spends your PLUMES balance.
Testfal_test_Free. Every generation answers with a small canned sound, so tests are fast and cost nothing.

An account can have several keys. They share one balance, one set of limits and one Catalyst identity. A key can expire; an expired key answers 401 KEY_EXPIRED.

Status codes

StatusMeaningWhat to do
401Missing, wrong, revoked or expired key. An expired key answers with KEY_EXPIRED.Check the key. Ask your administrator if it was revoked or to renew it.
402Your PLUMES balance is too low for this request.Ask your administrator to add PLUMES.
403Your key is not connected to Catalyst yet, the account is pending, or the key lacks a scope.Contact your administrator.
429Too many requests per minute, or too many at the same time.Wait for the Retry-After seconds and retry.
502The gateway could not reach Catalyst. PLUMES are returned.Retry after a short wait.

All errors share one shape: see Errors and status codes.