Quickstart
Make your first API call in five minutes — curl, Python, Node.js, or the OpenAI/Anthropic SDKs.
1. Get an API key
- Sign in to the portal.
- Open a project (or create one under Projects).
- Create an API key. The plaintext key is shown once at creation — store it in a secret manager, not in code.
Keys are hierarchical (Organisation → Project → API key) and carry their own model allowlist, IP allowlist, plan, rate limit, and optional spend cap.
2. Your first chat completion
curl https://api.<domain>/v1/chat/completions \
-H "Authorization: Bearer $TOKENFACTORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemma-4-31b-it",
"messages": [{"role": "user", "content": "Hello!"}]
}'3. What you get back
{
"id": "chatcmpl-1",
"object": "chat.completion",
"created": 1724680001,
"model": "google/gemma-4-31b-it",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help?", "refusal": null },
"finish_reason": "stop",
"logprobs": null
}
],
"usage": { "prompt_tokens": 5, "completion_tokens": 9, "total_tokens": 14 },
"provider_metadata": { "provider": "openai" }
}Two things to notice:
modelis the alias you sent, even when the internal serving model ID differs. The public model ID stays unchanged.provider_metadatais always present on every successful JSON body — you can code against it unconditionally.
4. Point an existing OpenAI integration at the gateway
The only two lines that change are base_url and api_key:
client = OpenAI(
base_url="https://api.<domain>/v1",
api_key=os.environ["TOKENFACTORY_API_KEY"],
)The same is true for TypeScript, Go, and any OpenAI-compatible tool (LangChain,
Vercel AI SDK, Cursor, etc.): set the base URL to https://api.<domain>/v1
and use an API key.
5. Try other modalities
Every modality follows the same pattern — alias in, standard body out:
| Task | Endpoint | Guide |
|---|---|---|
| Chat with tools/vision | POST /v1/chat/completions | Chat Completions |
| Streaming | stream: true on chat | Streaming |
| Embeddings | POST /v1/embeddings | Embeddings |
| Speech to text | POST /v1/audio/transcriptions | Transcriptions |
| Text to speech | POST /v1/audio/speech | Text to Speech |
Common first-call mistakes
| Symptom | Cause | Fix |
|---|---|---|
404 model_not_found | A provider-native id was sent (unlisted-model) or the alias is not on your key's allowlist. | Use a curated alias from Models in the portal. |
401 invalid_api_key | Key mistyped, revoked, or from another environment. | Re-copy the key; check you are on the right deployment. |
402 insufficient_funds | The organisation credit balance has no credit. | Top up in Billing, then retry. |
403 model_not_allowed | The key's model allowlist excludes the alias. | Add the alias to the key (Settings → API keys). |