Documentation
One OpenAI-compatible endpoint for different models. Go from your first request to streaming responses, one step at a time.
Four steps, from creating a key to reviewing usage. Choose cURL, Python or Node.js for the examples below.
Create an account and key
Create an API key in the console and configure its models and quota.
Manage API keysPoint your client at the API
Set the Base URL and read your Bearer key from the environment.
View Base URLBase URL
https://www.tokiai.ai/v1Set LEAPRIVER_KEY in your server environment first. Install the openai package for Python or the openai dependency for Node.js. Replace example/ model IDs with models available to your key.
curl https://www.tokiai.ai/v1/chat/completions \
-H "Authorization: Bearer $LEAPRIVER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "example/chat-model",
"messages": [{"role": "user", "content": "Say hi in one line."}]
}'View example responseMOCK
{
"id": "chatcmpl_example",
"object": "chat.completion",
"model": "example/chat-model",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 8,
"total_tokens": 22
}
}Send a Bearer key in the Authorization header of each request. Use an API key, not your console login token.
curl https://www.tokiai.ai/v1/models \
-H "Authorization: Bearer $LEAPRIVER_KEY" \
-H "Content-Type: application/json"Chat completions
/chat/completionsPass a conversation as an OpenAI-style messages array and receive an assistant message. Supported parameters depend on the model and the published API.
curl https://www.tokiai.ai/v1/chat/completions \
-H "Authorization: Bearer $LEAPRIVER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "example/chat-model",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Summarise this changelog."}
],
"max_tokens": 400,
"temperature": 0.2
}'Key parameters
| Parameter | Type | Notes |
|---|---|---|
modelRequired | string | Target model ID. Example IDs are not live models; select one from the available catalogue. |
messagesRequired | array | Conversation messages with role and content. Supported roles depend on the model. |
max_tokens | integer | Maximum output tokens, subject to the model's context and output limits. |
temperature | number | Sampling temperature. Availability and valid range depend on the model. |
stream | boolean | Use true for an SSE stream, otherwise receive the complete response. |
route | string | Prototype extension: price / latency / reliability routing preference. Omitted from copyable requests.Backend pending |
fallback | array | Prototype extension: backup models if the primary is unavailable. Omitted from copyable requests.Backend pending |
Streaming
/chat/completionsSet stream to true to receive Server-Sent Events (SSE). Stop reading at [DONE] and handle empty choices or delta values.
curl -N https://www.tokiai.ai/v1/chat/completions \
-H "Authorization: Bearer $LEAPRIVER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "example/chat-model",
"stream": true,
"messages": [{"role": "user", "content": "Count to five."}]
}'View example responseMOCK
data: {"choices":[{"index":0,"delta":{"content":"One"}}]}
data: {"choices":[{"index":0,"delta":{"content":", two, three, four, five."}}]}
data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]Listing models
/modelsList model IDs accessible to your key for your application's model selector. Extended pricing and context fields await backend confirmation.
curl https://www.tokiai.ai/v1/models \
-H "Authorization: Bearer $LEAPRIVER_KEY"View example responseMOCK
{
"object": "list",
"data": [
{
"id": "example/chat-model",
"object": "model",
"owned_by": "example"
},
{
"id": "example/vision-model",
"object": "model",
"owned_by": "example"
}
]
}Vision input
/chat/completionsCombine text and image_url entries in the message content array. Vision-enabled models can receive image URLs or base64 data URIs.
curl https://www.tokiai.ai/v1/chat/completions \
-H "Authorization: Bearer $LEAPRIVER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "example/vision-model",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What does this chart show?"},
{"type": "image_url", "image_url": {"url": "https://example.com/chart.png"}}
]
}]
}'Image URLs must be accessible to the server; valid base64 data URIs may also be used. Vision support, multiple images and size limits depend on the selected model.
Image generation
/images/generationsThe prototype's image endpoint returns image URLs or base64 data from a prompt. The example shows request syntax only; this page does not execute generation.
curl https://www.tokiai.ai/v1/images/generations \
-H "Authorization: Bearer $LEAPRIVER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "example/image-model",
"prompt": "Studio product photo of an amber glass bottle.",
"n": 1,
"size": "1024x1024"
}'Video generation
/videosThe prototype uses an asynchronous task: submit to obtain an ID, then query its status. These proposed HTTP examples avoid unconfirmed SDK extensions.
# 1. Submit an example task (proposed API; backend pending).
curl https://www.tokiai.ai/v1/videos \
-H "Authorization: Bearer $LEAPRIVER_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"example/video-model","prompt":"A quiet forest.","seconds":8}'
# 2. Replace job_example with the ID returned by the server.
curl https://www.tokiai.ai/v1/videos/job_example \
-H "Authorization: Bearer $LEAPRIVER_KEY"View example responseMOCK
{
"id": "job_example",
"status": "queued",
"model": "example/video-model"
}Example OpenAI-style errors and common recovery strategies. Distinguish input, authentication and transient service errors rather than retrying every failure.
| Status | Meaning | Action |
|---|---|---|
400 | Malformed request or invalid parameter | Check JSON, model ID and parameters. Do not retry unchanged. |
401 | Missing, invalid or disabled key | Check Authorization and key status before requesting again. |
429 | Rate or concurrency limit exceeded | Respect Retry-After and use bounded exponential backoff. |
502 / 503 | Upstream service temporarily unavailable | Limit retries; avoid duplicate tasks or charges for creation requests. |
529 | Prototype provider-overload status | Confirm published status codes. Retry later or choose an available model. |
View example responseMOCK
{
"error": {
"message": "Rate limit exceeded. Please retry later.",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}Limits depend on the API key and model configuration. The headers below illustrate request counts, remaining tokens and retry timing.
x-ratelimit-limit-requests: 3000
x-ratelimit-remaining-requests: 2987
x-ratelimit-limit-tokens: 400000000
x-ratelimit-remaining-tokens: 391204556
retry-after: 5These mock values are not actual quotas or an SLA. Respect Retry-After and use exponential backoff with a retry limit. Do not retry indefinitely.