DOCS / OPENAI-COMPATIBLE API

Connect once. Route to any supported model.

BestLLM uses the OpenAI Chat Completions API format. If your code already calls OpenAI, you can switch to BestLLM by changing two lines: the base URL and the API key. This guide walks through setup, authentication, request format, and common patterns.

Base URL

All API requests go through a single endpoint:

https://api.bestllm.dev/v1

This base URL serves all supported models — DeepSeek Chat, DeepSeek Reasoner, Qwen3.8 Max, Qwen Plus, Kimi K3, GLM-5, and MiniMax M3. The model is selected per-request via the model field in the request body. There are no separate endpoints per model.

Authentication

Create a live API key in the BestLLM Console. Store it server-side and send it as a Bearer token in the Authorization header. Never expose your API key in browser code or client-side JavaScript.

Authorization: Bearer $BESTLLM_API_KEY

Each API key is scoped to a workspace. Workspace-level spend controls, approved model routes, and regional policy all apply to requests made with that key.

Quickstart: Chat Completions

The chat completions endpoint accepts the same request format as OpenAI. Here is a complete example using curl:

curl -X POST https://api.bestllm.dev/v1/chat/completions \
  -H "Authorization: Bearer $BESTLLM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in one paragraph."}
    ],
    "temperature": 0.7,
    "stream": false
  }'

The response follows the OpenAI format:

{
  "id": "chatcmpl-bestllm-...",
  "object": "chat.completion",
  "created": 1728000000,
  "model": "deepseek-chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing uses qubits..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 22,
    "completion_tokens": 45,
    "total_tokens": 67
  }
}

SDK Setup: OpenAI Python SDK

The official OpenAI Python SDK works with BestLLM out of the box. Set the base URL and API key:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.bestllm.dev/v1",
    api_key="your-bestllm-api-key"
)

# Non-streaming
response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="qwen3-8-max",
    messages=[{"role": "user", "content": "Write a haiku"}],
    stream=True
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

SDK Setup: OpenAI Node.js SDK

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.bestllm.dev/v1",
  apiKey: process.env.BESTLLM_API_KEY,
});

const response = await client.chat.completions.create({
  model: "kimi-k3",
  messages: [{ role: "user", content: "Analyze this codebase" }],
});

console.log(response.choices[0].message.content);

Available Models

The following models are live and accessible through the BestLLM API. Use the model ID in the model field of your request. Each model page has full pricing, specs, and integration examples.

Model IDProviderContextInput /MOutput /M
deepseek-chatDeepSeek128K$0.30$1.19
deepseek-reasonerDeepSeek1M$1.79$3.57
qwen3-8-maxAlibaba Cloud1M$1.79$5.36
qwen-plusAlibaba Cloud256K$0.30$1.19
kimi-k3Moonshot AI1M$2.98$14.88
glm-5Zhipu AI (Z.ai)200K$0.60$2.68
minimax-m3MiniMax1M$0.31$1.25

Streaming

Set "stream": true in the request body to receive server-sent events (SSE). The response format matches OpenAI streaming: each chunk contains a delta object with partial content. BestLLM streams tokens as they arrive from the upstream provider with no additional buffering.

curl -X POST https://api.bestllm.dev/v1/chat/completions \
  -H "Authorization: Bearer $BESTLLM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [{"role": "user", "content": "Count to 10"}],
    "stream": true
  }'

Error Codes

BestLLM returns standard HTTP status codes with JSON error bodies:

CodeMeaning
401Invalid or missing API key
403Model route not approved for this workspace
404Unknown model or endpoint
429Rate limit exceeded — check workspace limits
502Upstream provider error — retry or switch model
503Model route temporarily unavailable

Rate Limits

Rate limits are configured per workspace and per API key. Default limits depend on your plan tier. If you receive a 429 response, the Retry-After header indicates how many seconds to wait before the next request. Contact support to raise limits for your workspace.

Full API reference

The public API reference is being expanded alongside the production Edge contract. The core surface — chat completions, streaming, model listing — is stable and production-ready. For questions about specific endpoints, request formats, or integration patterns, reach out through the Console support channel.

Browse all model pages → · View pricing → · Explore the platform →