API reference
The API's OpenAPI document makes these pages, so they change when the API does. Each page lists a route's fields and answers, and its playground sends the request.
| Route | What it does |
|---|---|
GET /v1/models | List the Base models. |
GET /v1/models/{model_id} | Read one Base model. |
GET /v1/models/{model_id}/status | Say whether a model is Warm. |
GET /v1/quota | Read your tokens this month and how many are left. |
POST /v1/tokenize | Turn a text into token ids, and count them. |
POST /v1/detokenize | Turn token ids into text. |
POST /v1/completions | Create a Completion. |
POST /v1/completion-jobs | Queue a Job. |
GET /v1/completion-jobs/{job_id} | Read a Job. |
GET /v1/completion-jobs/{job_id}/result | Fetch the result of a Job. |
POST /v1/completion-jobs/{job_id}/cancel | Cancel a Job. |
POST /v1/harvest | Queue a harvest Job of Activations. |
GET /v1/harvest | List your harvest Jobs, newest first. |
GET /v1/harvest/{job_id} | Read a harvest Job and its files, and wait for its status to change. |
DELETE /v1/harvest/{job_id} | Cancel a harvest Job. |
GET /v1/looms | List your Looms, pinned first. |
POST /v1/looms | Create a Loom. |
POST /v1/looms/import | Make a Loom from a file. |
GET /v1/looms/{loom_id} | Read a Loom. |
POST /v1/looms/{loom_id} | Rename or pin a Loom, or choose the API key that the App's Branches count for. |
GET /v1/looms/{loom_id}/export | Download a Loom as a file. |
GET /v1/looms/{loom_id}/stream | Follow a Loom as Server-Sent Events. |
POST /v1/looms/{loom_id}/cancel | Stop the Loom's growing Nodes. |
POST /v1/looms/{loom_id}/root | Replace the tree with a new root. |
DELETE /v1/looms/{loom_id} | Delete a Loom. |
POST /v1/looms/{loom_id}/nodes/{node_id} | Edit a Node. |
POST /v1/looms/{loom_id}/nodes/{node_id}/split | Split a Node at an offset. |
POST /v1/looms/{loom_id}/nodes/{node_id}/sibling | Write a Node beside a Node. |
POST /v1/looms/{loom_id}/nodes/{node_id}/child | Write a Node under a Node. |
POST /v1/looms/{loom_id}/nodes/{node_id}/favorite | Mark a Node as a Favorite, or take the mark off. |
POST /v1/looms/{loom_id}/nodes/{node_id}/branch | Branch from a Node of a Loom. |
DELETE /v1/looms/{loom_id}/nodes/{node_id} | Delete a Node and the Nodes under it. |
GET /health | Check that the API answers. |
POST /v1/chat/completions | Refuse every chat request with 400 and a message that names POST /v1/completions. |
Client labels
The API counts each Completion under a client label, so that you can split your usage by the script or tool that sent it. The label is the request's X-Title header, the header that OpenRouter reads. Without X-Title, it is the first product of the request's User-Agent, such as python-requests/2.32.3, OpenAI/Python, or curl/8.7.1, without its comments. A request with neither header has no label. The App's requests count as App.
The API trims the label, makes each run of spaces one space, and keeps its first 64 characters (Limits). It never refuses a request for its label. The API stores only the label, and keeps it as long as it keeps the Completion's usage.
This curl command names its request nightly-eval:
curl "$ACS_API_BASE/completions" \
-H "Authorization: Bearer $ACS_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Title: nightly-eval" \
-d '{"model": "llama-8b", "prompt": "The sky is", "max_tokens": 5}'This Python program names each request of its client nightly-eval:
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["ACS_API_BASE"],
api_key=os.environ["ACS_API_KEY"],
default_headers={"X-Title": "nightly-eval"},
)
completion = client.completions.create(model="llama-8b", prompt="The sky is", max_tokens=5)
print(completion.choices[0].text)GET /v1/quota with group_by=client adds clients to its answer: this UTC month's Completions under each label, the most tokens first. The App's Usage page shows the same split for the days, key, and model that you choose (Read your usage).
curl "$ACS_API_BASE/quota?group_by=client" \
-H "Authorization: Bearer $ACS_API_KEY"