LOW COST AI
עב

Authentication and API keys

Every call that touches your account has to prove who you are. There are three ways: an API key for code, the CLI and most AI assistants, a website sign-in for sensitive actions, and OAuth for assistants such as ChatGPT that cannot take a key. This page explains all three and what each may do.

Updated November 23, 2026

On this page
  1. Three ways to authenticate
  2. API keys
  3. How to send the key
  4. What a key can do and what only the website can
  5. OAuth for AI assistants
  6. Keeping your key safe

Three ways to authenticate

Authentication methods
MethodForHow
API keyCode, scripts, the CLI, Claude Code, CursorThe Authorization: Bearer header with the key
Website sign-inYou, in a browserA cookie set when you sign in to the site
OAuthAI assistants that connect to MCP, such as ChatGPTA consent screen on the site, after which the assistant gets a key of its own

Four endpoints are open to everyone with no authentication at all: list models, get model, estimate and the health check. Everything else needs a key or a sign-in.

API keys

An API key is a secret string that identifies your account. It looks like this: lca_ followed by 32 characters, 36 characters in all.

  • Where to create one. On the developers page, while signed in to the site. There is no way to create a key with another key
  • Shown once. We keep only a hashed fingerprint of the key, so it cannot be shown again. If you lose a key, revoke it and create a new one
  • Name. Each key has a name of up to 60 characters so you can tell it apart. The list also shows its first 10 characters, when it was created and when it was last used
  • Limit. Up to 25 active keys per account, and up to 20 new keys an hour
  • Revoking. Revoke on the developers page. It is immediate and final: every tool using the key stops working, and the key cannot be restored
  • Permissions. There are no partial scopes. A key acts for the whole account, except the sensitive actions in the table below

How to send the key

Send this header with every request:

Authorization: Bearer lca_your_key_here

For example, checking your balance:

curl https://low-cost.ai/api/v1/me -H "Authorization: Bearer $LCA_KEY"

A request with no key, a wrong key or a revoked key gets 401:

{ "error": "unauthorized" }

  • The value after Bearer must start with lca_. Any other value simply does not count as a key
  • If you send an invalid key, the request is refused even if it also carries a valid sign-in cookie
  • Every request made with a key updates its last used time, shown on the developers page

What a key can do and what only the website can

A key can do almost everything, but a few actions are kept for a website sign-in, so a leaked key cannot take over the account:

Permissions by method
ActionAPI keyWebsite sign-in
Models, estimates, generations, jobsYesYes
Files: list, upload, deleteYesYes
Balance, credit history, key listYesYes
Change name, language and colour themeYesYes
Create and revoke keysNoYes
Change the password and sign out sessionsNoYes
Delete the accountNoYes
Approve an OAuth connectionNoYes
Add creditsNoYes, on the credits page

A reserved action sent with a key gets 403 with web_session_required. Two more differences: a write request with a cookie must come from the site itself, otherwise it is refused with bad_origin, and the MCP endpoint does not accept a cookie at all, only a key.

OAuth for AI assistants

OAuth is a standard in which an app gets access to your account after you approve it on a screen of our site, without seeing your password and without you copying a key. ChatGPT, for example, cannot take an API key, so it connects this way. Here OAuth is used only to connect to the MCP endpoint, https://low-cost.ai/api/mcp.

What happens when you connect

  1. The app calls the MCP endpoint without a key and gets 401 with a pointer to the sign-in details
  2. A page on our site opens. If you are not signed in, you sign in first and come back to it automatically
  3. A consent screen shows the app name, what it will be able to do and the address you will return to
  4. You approve. The app gets an API key of its own, named after the app followed by (OAuth)
  5. The key shows on the developers page like any other key, and that is also where you disconnect it

What the consent screen says

  • The app will be able to create images, video and audio with your credits. Every paid generation asks for your confirmation inside the app
  • It will be able to see the models, prices, your generations, files and balance
  • It will be able to delete files from your library, only when you ask
  • It will not see your password, cannot add funds and cannot change your account details
  • The address you return to after approving, and the account you are signed in with

Pressing Cancel sends the app the error access_denied, and no key is created. A malformed request from the app shows an error page with details for developers, and nothing is sent to the app.

For app developers: the technical details

The server follows the MCP authorization specification. PKCE is a mechanism in which the app proves it is the one that started the sign-in, without a fixed secret: it sends a fingerprint of a random string at the start and the string itself at the end. It is required here, with the S256 method. The discovery addresses:

curl https://low-cost.ai/.well-known/oauth-authorization-server curl https://low-cost.ai/.well-known/oauth-protected-resource/api/mcp

The answer of the first one:

{ "issuer": "https://low-cost.ai", "authorization_endpoint": "https://low-cost.ai/oauth/authorize", "token_endpoint": "https://low-cost.ai/api/oauth/token", "registration_endpoint": "https://low-cost.ai/api/oauth/register", "response_types_supported": ["code"], "grant_types_supported": ["authorization_code"], "code_challenge_methods_supported": ["S256"], "token_endpoint_auth_methods_supported": ["none"], "scopes_supported": ["lowcostai"], "client_id_metadata_document_supported": true, "authorization_response_iss_parameter_supported": true, "service_documentation": "https://low-cost.ai/docs" }

  • Identifying the app. Two ways: a client_id that is an https URL of a Client ID Metadata Document, or dynamic registration with POST /api/oauth/register carrying redirect_uris, 1 to 5 https addresses, and client_name. With dynamic registration token_endpoint_auth_method must be none
  • Redirect addresses. https only, or http only for localhost, 127.0.0.1 and [::1], and no #
  • The code. Valid for 5 minutes and single use. Exchange it with POST /api/oauth/token carrying grant_type=authorization_code, code, code_verifier and redirect_uri. The body may be a form or JSON
  • resource. If sent, it must be https://low-cost.ai/api/mcp
  • scope. There is just one: lowcostai

The token answer:

{ "access_token": "lca_<32 characters>", "token_type": "Bearer", "scope": "lowcostai" }

access_token is an ordinary API key. It works on MCP and on every REST endpoint, it does not expire and there is no refresh_token. It stays active until it is revoked on the developers page.

Keeping your key safe

An API key is as good as a password: whoever holds it can generate with your credits and delete your files.

  • Keep it in an environment variable or a secrets manager, not in code
  • Never commit it to a code repository, private ones included, and never paste it into messages
  • Never put it in code that runs in a browser or in an app you ship to users
  • Use a separate key for each computer and tool, with a clear name, so you revoke only what leaked
  • Revoke a leaked key right away on the developers page and create a new one
  • The CLI keeps the key in ~/.lowcostai/config.json, readable by the owner only, and sends it only over https and only to the service address

max_credits adds another layer: even a leaked key cannot generate without naming a price cap on every generation. Still, revoke it at once.