Skip to content

Authentication and API keys

This page describes how requests to the Inola API are authenticated: the API key, its permissions, expiry and revocation. It needs access to the console of your organization to create keys.

Every request carries an API key in the Authorization header:

Authorization: Bearer <the secret of the key>

Live keys start with ck_live_. A request without the header, or with an unknown or revoked key, returns 401 invalid_api_key.

Keys are created in the console (https://console.inola.ai, section API keys). A key belongs to an organization; the usage of all its keys is billed to that organization, and files and batches created with one key are visible to every key of the same organization.

The secret is shown once, when the key is created. It cannot be shown again: a lost secret is replaced by a new key.

A key has one or more permissions (scopes):

permissionallows
inferencerequests to models (POST /v1/infer), files and batches (/v1/files, /v1/batches)
models:readthe model list (GET /v1/models)
usage:readusage statistics

A request to an endpoint the key has no permission for returns 403 insufficient_scope.

  • A key can have an expiry date. After it, requests with the key return 401 api_key_expired.
  • A revoked key stops working within seconds; its requests return 401 invalid_api_key.
  • A key of a suspended organization returns 403 account_suspended; a key of an organization with no balance left returns 402 payment_required.

Replacing a key without downtime: create a new key, deploy it where the old one was used, check that requests with the new key succeed, then revoke the old key.

The key is a secret: anyone who has it can make requests billed to your organization. The examples in this documentation read it from the INOLA_API_KEY environment variable. On servers, a secret manager or the environment of the process keeps it out of the source code and the repository. A key placed in browser or mobile app code can be read by every user of the app, so requests with it are made from a server.

Example: a request and an authentication error

Section titled “Example: a request and an authentication error”

The scripts below send one request and report an authentication problem by its code.

Terminal window
curl -sS -i "https://api.inola.ai/v1/infer" \
-H "Authorization: Bearer $INOLA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "cordon-mini", "input": {"state": "Meeting notes, 14 October: the vendor contract renews on 1 March."}}'
import os
import sys
import requests
API_URL = "https://api.inola.ai"
API_KEY = os.environ.get("INOLA_API_KEY")
if not API_KEY:
sys.exit("INOLA_API_KEY is not set")
response = requests.post(
f"{API_URL}/v1/infer",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"model": "cordon-mini", "input": {"state": "Meeting notes, 14 October: the vendor contract renews on 1 March."}},
timeout=30,
)
if response.status_code in (401, 402, 403):
error = response.json()["error"]
sys.exit(f"The key was refused: {response.status_code} {error['code']}: {error['message']}")
response.raise_for_status()
print("The key works; request id", response.headers["X-Request-Id"])
const API_URL = "https://api.inola.ai";
const apiKey = process.env.INOLA_API_KEY;
if (!apiKey) {
console.error("INOLA_API_KEY is not set");
process.exit(1);
}
const response = await fetch(`${API_URL}/v1/infer`, {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify({ model: "cordon-mini", input: { state: "Meeting notes, 14 October: the vendor contract renews on 1 March." } }),
});
if ([401, 402, 403].includes(response.status)) {
const { error } = await response.json();
console.error(`The key was refused: ${response.status} ${error.code}: ${error.message}`);
process.exit(1);
}
if (!response.ok) {
console.error(`Request failed with status ${response.status}`);
process.exit(1);
}
console.log("The key works; request id", response.headers.get("X-Request-Id"));

A revoked or mistyped key returns:

HTTP/2 401
content-type: application/json
x-request-id: req_01JBXR2D9F4H6K8M0P3S5V7X9Z
{"error": {"code": "invalid_api_key", "message": "Invalid API key."}}
statuscodecause
401invalid_api_keythe header is missing, or the key is unknown or revoked
401api_key_expiredthe key is past its expiry date
402payment_requiredthe organization has no balance left, or a payment failed
403insufficient_scopethe key lacks the permission for this endpoint
403account_suspendedthe organization is suspended

Rejected requests are not billed.