One key. A familiar API.
Use an app-issued TokensAreOnMe key to call our OpenAI-style chat endpoint. This key is not an OpenAI or other provider key; provider credentials stay server-side.
Quickstart
Set your app-issued key, the API base URL, and a model ID from the approved catalog. Keep the key out of source control and browser code. Every request can incur a retail charge; begin only with an amount you are willing to spend.
curl --fail-with-body --retry 0 --max-time 30 \
-H "Authorization: Bearer $TOKENSAREONME_API_KEY" \
"${TOKENSAREONME_BASE_URL:-https://tokensareonme.com/v1}/models"
An idempotency header is optional for an ordinary request: the gateway assigns a request identity when it is absent. The examples include an explicit key for clarity; supplying one is recommended when you may retry. Turn off automatic SDK retries unless you configure a stable explicit key, because SDK retries require one. Inspect an uncertain request rather than blindly replaying it; see the advanced reference for receipts and safe retries.
Choose a model
Fetch GET /v1/models and use an exact
id from its response. Example IDs can change; the chat
snippet below uses openai/gpt-6.1-sol as an illustration
only. No universal provider registry is available today.
Pricing before you send
There is no approved public per-model rate card today, so no per-token rate is quoted here. Rates may vary by exact model, route, input, output, cached or reasoning tokens, and supplier terms. Before paid access is enabled, a rate card must be approved for each exact model and tied to verified cost for the actual supplier route; catalog listings or estimates are not that evidence.
We use the authoritative primary supplier billing record. We round the
confirmed cost up to a whole microdollar (US$0.000001), apply the 50%
markup for new retail purchases, then round up again to a whole
microdollar. A cost of US$1.00 therefore uses US$1.50 in credit. A
pre-dispatch reservation is only an estimate/temporary hold based on
request size and output limit—not supplier cost and not a final
charge. Actual confirmed cost determines the charge; a hold is
released or reconciled afterward. API requests currently cap
max_tokens at 4096, and the request must fit the selected
model's context window. The public API is disabled; these limits and
pricing describe intended behavior, not an active offer.
Chat completions
Send JSON to POST /v1/chat/completions. Required fields
are a catalog model, messages with
role and content,
max_tokens from 1 to 4096 (1024 applies when omitted;
values above 4096 are lowered to 4096). Tool calling with
tools and tool_choice is supported. With
stream: true the complete answer arrives in one event
after the model finishes. Content is text only, and a request must fit
the model's context window measured in bytes (about 120 KB for
most models). Unsupported parameters are rejected with a message
naming them.
To use your key in a coding agent or chat client, see the integration guide.
curl --fail-with-body --retry 0 --max-time 30 \
-X POST "${TOKENSAREONME_BASE_URL:-https://tokensareonme.com/v1}/chat/completions" \
-H "Authorization: Bearer $TOKENSAREONME_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"model":"openai/gpt-6.1-sol","messages":[{"role":"user","content":"Hello"}],"max_tokens":32,"stream":false}'
Set TOKENSAREONME_API_KEY before running. The base URL
defaults to https://tokensareonme.com/v1; change it only
for a trusted test environment. Choose the model ID from the live
catalog when the API is enabled.
import json
import os
import urllib.error
import urllib.request
import uuid
base = os.environ.get("TOKENSAREONME_BASE_URL", "https://tokensareonme.com/v1").rstrip("/")
body = json.dumps({
"model": "openai/gpt-6.1-sol",
"messages": [{"role": "user", "content": "Hello"}],
"max_tokens": 32,
"stream": False,
}).encode()
request = urllib.request.Request(
base + "/chat/completions", data=body, method="POST",
headers={
"Authorization": "Bearer " + os.environ["TOKENSAREONME_API_KEY"],
"Content-Type": "application/json",
"Idempotency-Key": str(uuid.uuid4()),
},
)
try:
with urllib.request.urlopen(request, timeout=30) as response:
print(response.read().decode())
except urllib.error.URLError as error:
raise SystemExit(f"Request failed; inspect before retrying: {error}")
import { randomUUID } from "node:crypto";
const base = (process.env.TOKENSAREONME_BASE_URL || "https://tokensareonme.com/v1").replace(/\/$/, "");
const response = await fetch(`${base}/chat/completions`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TOKENSAREONME_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": randomUUID(),
},
body: JSON.stringify({
model: "openai/gpt-6.1-sol",
messages: [{ role: "user", content: "Hello" }],
max_tokens: 32,
stream: false,
}),
signal: AbortSignal.timeout(30_000),
});
console.log(await response.text());
Advanced reference: explicit request IDs and safe retries
Send a unique Idempotency-Key (1–128 letters, digits,
., _, :, or -) for
each intended logical request. Reuse the same value only when safely
checking that same attempt. Repeating the same request returns
409 request_already_recorded—it does not replay or cache
a successful answer. Reusing it with a changed body returns
409 idempotency_conflict.
Examples generate a fresh ID per intended call and do not retry automatically. Do not blindly retry after a timeout or uncertain response.
Advanced reference: receipts, billing_unknown, billing and reconciliation
For a response containing request_id, query the
documented receipt route:
GET /api/gateway/requests/{request_id} with the same
wallet spending key in the Bearer header. The receipt reports state,
retail_charge_micros, and wallet available, held, and
used amounts. A failed request is not necessarily free. A
502 billing_unknown can mean a hold may have been
consumed: preserve the request ID, inspect its receipt, and do not
blindly repeat.
Reconciliation is an owner-authorized operation, not an ordinary spending-key action. Optional passwordless accounts can link purchase history; they do not enable the prelaunch-gated public runtime.
Customer and downstream-user responsibilities
If you use the API to provide access to other people, you are responsible for restricting your downstream users to people who are at least 18 years old and legally capable of entering into a binding agreement. You must bind those users to applicable protective terms and the selected providers’ usage policies. Violations may result in access suspension or termination, subject to applicable law.
Protect your key
- Store the issued key in a secret manager or server-side environment variable; never commit, log, or expose it in a browser.
- Never send your app-issued key to an upstream provider. Provider credentials are kept server-side.
- Do not paste real keys into online playgrounds or share them in support messages. This guide has no key-entry field and stores no key.
- Wallet budget is shared across keys for that wallet; separate keys do not create separate credit.
The retail charge billed to you is distinct from the provider's underlying cost and is not a statement of TokensAreOnMe profit.
The protocol is documented here for early integration work. The public API remains disabled until launch.