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.
The Authorization header
Section titled “The Authorization header”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 and organizations
Section titled “Keys and organizations”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.
Permissions
Section titled “Permissions”A key has one or more permissions (scopes):
| permission | allows |
|---|---|
inference | requests to models (POST /v1/infer), files and batches (/v1/files, /v1/batches) |
models:read | the model list (GET /v1/models) |
usage:read | usage statistics |
A request to an endpoint the key has no permission for returns 403 insufficient_scope.
Expiry and revocation
Section titled “Expiry and revocation”- 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 returns402 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.
Where the key is kept
Section titled “Where the key is kept”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.
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."}}'Python
Section titled “Python”import osimport 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"])JavaScript
Section titled “JavaScript”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 401content-type: application/jsonx-request-id: req_01JBXR2D9F4H6K8M0P3S5V7X9Z
{"error": {"code": "invalid_api_key", "message": "Invalid API key."}}Authentication errors
Section titled “Authentication errors”| status | code | cause |
|---|---|---|
| 401 | invalid_api_key | the header is missing, or the key is unknown or revoked |
| 401 | api_key_expired | the key is past its expiry date |
| 402 | payment_required | the organization has no balance left, or a payment failed |
| 403 | insufficient_scope | the key lacks the permission for this endpoint |
| 403 | account_suspended | the organization is suspended |
Rejected requests are not billed.
Next steps
Section titled “Next steps”- Quickstart — the first request.
- Error codes — every code and what to do.
- Glossary — the terms used here.