Docs

OpenAI-Compatible API

Updated 2026-07-21

/v1/chat/completions is the most widely supported endpoint across providers. Replace the Base URL in the official OpenAI SDK with https://api.rokoapi.com/v1 to call available models on this platform.

This page covers the compatibility mode. If you need the native OpenAI Responses protocol, see Responses API.

Why use compatibility mode

  • One codebase, multiple models: The same SDK can call available channels such as DeepSeek, OpenAI, and image models
  • Mature ecosystem: LangChain, various IDE plugins, and proxy clients default to Chat Completions
  • Low migration cost: Only change base_url / baseURL and model

Switch to Responses when you need its structured output, semantic streaming events, or capabilities available only through that upstream endpoint. See Responses API.

Quick start

curl https://api.rokoapi.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [
      {"role": "system", "content": "You are a concise assistant"},
      {"role": "user", "content": "Introduce yourself in one sentence"}
    ]
  }'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.rokoapi.com/v1",
)

resp = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[
        {"role": "system", "content": "You are a concise assistant"},
        {"role": "user", "content": "Introduce yourself in one sentence"},
    ],
)
print(resp.choices[0].message.content)
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.rokoapi.com/v1',
})

const resp = await client.chat.completions.create({
  model: 'deepseek-v4-flash',
  messages: [
    { role: 'system', content: 'You are a concise assistant' },
    { role: 'user', content: 'Introduce yourself in one sentence' },
  ],
})

console.log(resp.choices[0]?.message?.content)

model model must use a valid model ID from the available models guide; do not use unprovisioned names.

Request parameters reference

ParameterTypeDescription
modelstringRequired, available model ID
messagesarrayRequired, conversation messages
streambooleantrue Returns SSE when true
temperaturenumberSampling temperature; may not be supported by some reasoning models
max_tokens / max_completion_tokensintMaximum output length
tools / tool_choiceFunction calling; support depends on model and channel
response_formatobjectOutput format constraints, such as JSON

For detailed field descriptions, see Chat Completions.

Response structure

On success, returns standard Chat Completion JSON with text in choices[0].message.content. On error, typically includes error.message(and optionally error.type / error.code).

Streaming output

Set "stream": true. For streaming details, see Streaming requests.

Non-text capabilities (e.g., images)

For image generation, use the corresponding endpoint (e.g., /v1/images/generations) and replace model with an image model ID. See the sidebar under “Available models” for examples by series. model Replace with an image model ID. See the sidebar under Available Models for examples by series.