Base URL
/v1 and use JSON. The OpenAPI specification is available at https://api.tokenchange.io/v1/openapi.json.
Authentication
Authenticate with an API token as a Bearer token:tcg_. They can’t make inference requests, and inference keys can’t call the REST API.
Create an API token
1
Open API tokens
In the dashboard, open Account > API tokens.
2
Name the token and choose scopes
Use a name that says where the token runs, such as
deploy pipeline. Pick only the scopes it needs, and optionally an expiry.3
Copy the token
The token is shown once. Store it in a secret manager.
Scopes
Each token carries one or more scopes. A request to a route outside the token’s scopes fails with403 insufficient_scope. Write scopes don’t include the matching read scope, so add both if you need both.
Each route’s required scope is listed on its reference page.
Units
Credit amounts are integers in microcredits, in fields ending in_micro. One credit is 1,000,000 microcredits, and one credit is worth $0.01. Prices are decimal strings in USD per million tokens.
Pagination
List routes return a page of results and a cursor:next_cursor as the cursor query parameter to get the next page. limit sets the page size, from 1 to 100 (default 20). When there are no more results, next_cursor is null.
Rate limits
Requests are rate-limited per token and per account in one-minute windows. Every authenticated response includes the limit that’s closest to running out:
Over the limit, you get
429 rate_limited with a Retry-After header in seconds.
Idempotency
POST routes accept an optional Idempotency-Key header of 1 to 255 printable ASCII characters. Send a unique value, such as a UUID, to retry a request safely:
- Retrying with the same key and the same request returns the original response with
Idempotent-Replayed: true, for 24 hours. - Reusing a key with a different request fails with
422 idempotency_key_reused. - Retrying while the first request is still running fails with
409 idempotency_in_progress. - Responses that contain a secret, such as a new inference key, are never stored. Replaying one fails with
409 idempotency_secret_unavailable, andresource_idholds the ID of the key that was created.
Request IDs
Every response has anX-Request-Id header. Send your own X-Request-Id (up to 128 letters, digits, -, _ or .) to use it instead. Include it when you contact support.