Skip to content
Docs

API reference

Authentication and API keys

Every request carries a Libremodel API key. One header, two accepted spellings, so both the OpenAI and the Anthropic SDKs work as they come.

Send the key

Send the key in either of these headers. Both work on every endpoint, whichever format you use:

Accepted headers
HeaderSent by
Authorization: Bearer sk-libremodel-...The OpenAI SDKs, and most HTTP clients
x-api-key: sk-libremodel-...The Anthropic SDKs
curl https://api.libremodel.ai/v1/chat/completions \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-v4.1-flash-1017", "messages": [{"role": "user", "content": "Hi"}]}'

Key format

Keys start with sk-libremodel-, followed by 43 random characters. The fixed prefix makes a key easy to recognize if it ever shows up in code or logs.

Create and manage keys

  • Keys are created in API keys. Each one needs a name. Optionally, give it an expiration date, a spending limit (total, or reset every day, week or month), the models it can use and how many requests it can run at once.
  • The full key is shown once, when you create it. We only keep a fingerprint of it, so nobody, us included, can show it to you again. If you lose it, create a new one.
  • The list shows each key by its last four characters, with its creation date and last use.
  • Deleting a key is immediate: apps that use it stop working within a second. It cannot be undone.

Keys and your balance

Keys belong to your organization, and so does the balance. Every key draws from the same prepaid credit, on every model. Details in Billing and credits.

Identify your app

If you build an app or a tool on top of the API, send these two optional headers, the same ones OpenRouter uses. They tell your app’s usage apart from the rest. They don’t change the response, the routing or the price.

Optional headers
HeaderWhat it is
HTTP-RefererYour app’s URL, for example https://example.com.
X-TitleYour app’s name, for example My App.
curl https://api.libremodel.ai/v1/chat/completions \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY" \
  -H "HTTP-Referer: https://example.com" \
  -H "X-Title: My App" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-v4.1-flash-1017", "messages": [{"role": "user", "content": "Hi"}]}'

When authentication fails

Authentication errors
StatusCodeWhen
401invalid_api_keyThe header is missing, or the key does not exist, has expired or was deleted.
403account_suspendedThe key is valid, but its account is suspended. Contact us.

All error codes: Limits and errors.

Keep it safe

  • Call the API from your server. A key in a web page or a mobile app is a key anyone can read.
  • Use one key per app or environment, so you can delete one without touching the others.
  • If a key leaks, delete it in API keys and create a new one.