API Reference
OpenAI-compatible. Switch in 30 seconds.
🚀 Overview
OneAI provides an OpenAI-compatible API. If you already use the OpenAI SDK, just change base_url and api_key — everything else works identically.
Base URL
https://api.oneai.io/v1
Auth Header
Authorization: Bearer oneai-sk-...
🔑 Authentication
All API requests require an API key. Get yours from the dashboard.
# Option 1: Environment variable
export ONEAI_API_KEY="oneai-sk-your-key-here"
# Option 2: Pass directly in code
import openai
client = openai.OpenAI(
api_key="oneai-sk-your-key-here",
base_url="https://api.oneai.io/v1"
)
💬 Chat Completions
POST
/v1/chat/completions
Send a conversation and get a model response.
from openai import OpenAI
client = OpenAI(
api_key="oneai-sk-...",
base_url="https://api.oneai.io/v1"
)
response = client.chat.completions.create(
model="deepseek-v4-pro",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
Parameters
| Parameter | Type | Description |
|---|---|---|
model | string | Model ID (e.g. deepseek-v4-pro) |
messages | array | Conversation history |
temperature | float | 0-2. Higher = more random |
max_tokens | int | Max output length |
stream | boolean | Enable streaming |
📡 Streaming
Stream responses token-by-token for real-time output.
stream = client.chat.completions.create(
model="deepseek-v3",
messages=[{"role": "user", "content": "Write a haiku about AI"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
🧠 Available Models
| Model ID | Provider | Context | Input/1M | Output/1M |
|---|---|---|---|---|
| deepseek-v4-pro | DeepSeek | 128K | $1.00 | $4.00 |
| deepseek-v4-flash | DeepSeek | 128K | $0.30 | $1.20 |
| deepseek-r1 | DeepSeek | 128K | $0.80 | $3.50 |
| deepseek-v3 | DeepSeek | 128K | $0.50 | $2.19 |
| deepseek-r1 | DeepSeek | 128K | $0.55 | $2.19 |
| qwen-coder | Alibaba | 128K | $0.40 | $1.60 |
| qwen-max | Alibaba | 32K | $0.60 | $2.40 |
| kimi | Moonshot | 128K | $0.40 | $1.60 |
| minimax-m1 | MiniMax | 1M | $0.35 | $1.40 |
| glm-4 | Zhipu | 128K | $0.30 | $1.20 |
⚠️ Error Codes
401Invalid or missing API key
402Insufficient balance — top up your account
429Rate limit exceeded — slow down or upgrade
500Server error — we're on it. Retry with backoff
503Model overloaded — try again or switch models
⏱ Rate Limits
| Tier | RPM | TPM | Concurrent |
|---|---|---|---|
| Free | 20 | 200K | 2 |
| Pro | 200 | 2M | 10 |
| Enterprise | Custom | Custom | Custom |