OpenAI-Compatible API

Complete guide to POST /v1/chat/completions and POST /v1/responses. Request schema, tool calling, multi-modal images, and streaming.

Toknix provides complete protocol parity with OpenAI's v1 Chat Completions and Responses API. Any application, SDK, or framework designed for OpenAI can interact with Toknix models without architectural refactoring.

Chat Completions

Endpoint: POST https://api.toknix.in/v1/chat/completions

bash
curl https://api.toknix.in/v1/chat/completions   -H "Authorization: Bearer $TOKNIX_API_KEY"   -H "Content-Type: application/json"   -d '{
    "model": "gpt-6-astra",
    "messages": [
      {"role": "system", "content": "You are a senior software architect."},
      {"role": "user", "content": "Explain write-ahead logs in database engines."}
    ],
    "temperature": 0.2,
    "max_tokens": 1024
  }'

Supported Parameters

ParameterTypeDescription
modelstringRequired. The model identifier (e.g., gpt-6-astra, claude-opus-5-5, deepseek-v4.1-flash).
messagesarrayRequired. Array of message objects containing role (system, user, assistant, tool) and content.
streambooleanOptional. Defaults to false. When true, tokens stream over Server-Sent Events (SSE).
temperaturenumberOptional. Sampling temperature between 0.0 and 2.0.
max_tokensintegerOptional. Maximum tokens to generate before stopping.
toolsarrayOptional. Array of tool objects available for the model to call.
tool_choicestring | objectOptional. Controls whether the model must invoke a tool (none, auto, required).
reasoning_effortstringOptional. For reasoning models (low, medium, high).

Function & Tool Calling

Toknix translates standard OpenAI tool definitions into provider-native tool schemas across all supported frontier models:

json
{
  "model": "claude-sonnet-5-5",
  "messages": [
    {"role": "user", "content": "What is the token balance for account 8391047215?"}
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_wallet_balance",
        "description": "Look up real-time prepaid balance in USD for a Toknix account",
        "parameters": {
          "type": "object",
          "properties": {
            "account_id": {"type": "string", "description": "10-digit numerical PIN"}
          },
          "required": ["account_id"]
        }
      }
    }
  ],
  "tool_choice": "auto"
}

Vision & Multimodal Payloads

Send images as base64 strings or publicly accessible URLs in the content array:

json
{
  "model": "gemini-4-carbon",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Describe the architecture diagram in this image."},
        {
          "type": "image_url",
          "image_url": {
            "url": "https://toknix.in/brand/toknix-banner.jpg"
          }
        }
      ]
    }
  ]
}

Responses API (POST /v1/responses)

Toknix supports OpenAI's modern Responses API endpoint at POST https://api.toknix.in/v1/responses. This endpoint provides structured input/output primitives optimized for modern autonomous agent loops and multimodal workflows.