TOKI
API Reference

API Overview

Overview of TOKI OpenAI-compatible REST API endpoints and conventions.

Base URL

All API requests should be made to:

https://www.tokiai.ai/v1

Request Format

  • All requests must use HTTPS
  • Request bodies should be JSON-encoded
  • Include Content-Type: application/json header
  • Include Authorization: Bearer YOUR_API_KEY header

Response Format

Chat completion responses follow the common OpenAI Chat Completions structure:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1714000000,
  "model": "deepseek/deepseek-chat-v3",
  "choices": [...],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 20,
    "total_tokens": 30
  }
}

Error Handling

Errors generally return appropriate HTTP status codes with a JSON error body:

Status CodeDescription
400Bad Request — Invalid parameters
401Unauthorized — Invalid API key
403Forbidden — Insufficient permissions
429Too Many Requests — Rate limit exceeded
500Internal Server Error
{
  "error": {
    "code": "invalid_request",
    "message": "The 'model' field is required.",
    "type": "invalid_request_error"
  }
}

Different models, quota states, and API key states may return different messages. Clients should read error.message and handle it together with the HTTP status code.

Common Endpoints

MethodPathDescription
POST/chat/completionsCreate a chat completion.
GET/modelsList currently available models; availability depends on the current server implementation.

Streaming

TOKI supports server-sent events (SSE) for streaming responses. Set stream: true in your request:

const stream = await openai.chat.completions.create({
  model: 'deepseek/deepseek-chat-v3',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

On this page