HomeDocumentation

Documentation

One OpenAI-compatible endpoint for different models. Go from your first request to streaming responses, one step at a time.

API DOCUMENTATION · PREVIEWStart building

Four steps, from creating a key to reviewing usage. Choose cURL, Python or Node.js for the examples below.

/01

Create an account and key

Create an API key in the console and configure its models and quota.

Manage API keys
/02

Point your client at the API

Set the Base URL and read your Bearer key from the environment.

View Base URL
/03

Pick a model ID

Browse the catalogue and choose a model accessible to your key.

Choose a model
/04

Review your usage

Check requests and consumption in the usage dashboard.

Open usage dashboard

Base URL

Base URL
https://www.tokiai.ai/v1

Set 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
View example response
{
  "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"
Keep keys in server-side environment variables, never in Git, browser code or shared messages. Use separate keys for development and production. Disable and replace any exposed key.

Chat completions

POST/chat/completions

Pass 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

ParameterTypeNotes
modelRequiredstringTarget model ID. Example IDs are not live models; select one from the available catalogue.
messagesRequiredarrayConversation messages with role and content. Supported roles depend on the model.
max_tokensintegerMaximum output tokens, subject to the model's context and output limits.
temperaturenumberSampling temperature. Availability and valid range depend on the model.
streambooleanUse true for an SSE stream, otherwise receive the complete response.
routestringPrototype extension: price / latency / reliability routing preference. Omitted from copyable requests.Backend pending
fallbackarrayPrototype extension: backup models if the primary is unavailable. Omitted from copyable requests.Backend pending

Streaming

POST/chat/completions

Set 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
View example response
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

GET/models

List 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"

Browse models →

View example responseMOCK
View example response
{
  "object": "list",
  "data": [
    {
      "id": "example/chat-model",
      "object": "model",
      "owned_by": "example"
    },
    {
      "id": "example/vision-model",
      "object": "model",
      "owned_by": "example"
    }
  ]
}

Vision input

POST/chat/completions

Combine 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

POST/images/generations

The 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"
  }'

The 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"
This is the prototype's proposed asynchronous contract, not a connected generation service. Check queued / processing / completed / failed states after submission. SDK methods, polling policies and result URL expiry await backend confirmation.
View example responseMOCK
View example response
{
  "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.

StatusMeaningAction
400Malformed request or invalid parameterCheck JSON, model ID and parameters. Do not retry unchanged.
401Missing, invalid or disabled keyCheck Authorization and key status before requesting again.
429Rate or concurrency limit exceededRespect Retry-After and use bounded exponential backoff.
502 / 503Upstream service temporarily unavailableLimit retries; avoid duplicate tasks or charges for creation requests.
529Prototype provider-overload statusConfirm published status codes. Retry later or choose an available model.
View example responseMOCK
View example response
{
  "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.

Example response headers
x-ratelimit-limit-requests: 3000
x-ratelimit-remaining-requests: 2987
x-ratelimit-limit-tokens: 400000000
x-ratelimit-remaining-tokens: 391204556
retry-after: 5

These mock values are not actual quotas or an SLA. Respect Retry-After and use exponential backoff with a retry limit. Do not retry indefinitely.

Start with your first API request

Create a key, choose a model, and connect your application. Verify the API version and model capabilities before going live.

Browse models