Docs · Quickstart
3 minutes. One line of code.
Planet AI speaks OpenAI, Anthropic, and Gemini protocols natively. Pick your favorite SDK, change one URL, get 100+ models.
Endpoints
Three protocols, one key
| Protocol | Base URL | Auth header |
|---|---|---|
| OpenAI-compatible | https://api.withplanetai.cn/v1 | Authorization: Bearer sk-pl-... |
| Anthropic native | https://api.withplanetai.cn/anthropic/v1 | x-api-key: sk-pl-... |
| Gemini native | https://api.withplanetai.cn/gemini/v1beta | x-goog-api-key: sk-pl-... |
You can use any one protocol to call any upstream model — e.g. call anthropic/claude-sonnet-4.6 through the OpenAI endpoint. Planet AI translates protocols transparently.
Naming
provider/model — the only naming rule
Every model is referenced as provider/model-id:
openai/gpt-5.4anthropic/claude-sonnet-4.6google/gemini-3.5-flashdeepseek/deepseek-v4-proqwen/qwen-3.6-flashmoonshot/kimi-k2.6zhipu/glm-4-flashxai/grok-4.20mistral/mistral-large-3Full list at /models.
OpenAI-compatible (recommended)
Change base_url. Done.
from openai import OpenAI
client = OpenAI(
base_url="https://api.withplanetai.cn/v1",
api_key="sk-pl-...", # your Planet AI key
)
resp = client.chat.completions.create(
model="anthropic/claude-sonnet-4.6", # any provider/model id
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.withplanetai.cn/v1",
apiKey: process.env.PLANET_AI_KEY,
});
const resp = await client.chat.completions.create({
model: "openai/gpt-5.4",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);Anthropic native
Use the Claude SDK as-is.
import anthropic
client = anthropic.Anthropic(
base_url="https://api.withplanetai.cn/anthropic/v1",
api_key="sk-pl-...",
)
resp = client.messages.create(
model="anthropic/claude-opus-4.7",
max_tokens=512,
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.content[0].text)The same anthropic/claude-* models are also reachable via the OpenAI-compatible endpoint above. Use whichever fits your stack.
Gemini native
Use the Google GenAI SDK.
from google import genai
client = genai.Client(
api_key="sk-pl-...",
http_options={
"base_url": "https://api.withplanetai.cn/gemini",
},
)
resp = client.models.generate_content(
model="google/gemini-3.5-flash",
contents="Hello",
)
print(resp.text)The Gemini native entry currently translates from google/* models only. For non-Google models, prefer the OpenAI-compatible endpoint.
Capabilities
Streaming
# OpenAI Python SDK, stream=True
stream = client.chat.completions.create(
model="anthropic/claude-haiku-4-5",
messages=[{"role": "user", "content": "Stream three numbers"}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)SSE chunks arrive in OpenAI delta format regardless of upstream protocol. Planet AI translates Claude / Gemini event streams into OpenAI deltas transparently.
Capabilities
Function calling
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
resp = client.chat.completions.create(
model="openai/gpt-5.4",
tools=tools,
tool_choice="auto",
messages=[{"role": "user", "content": "Weather in Tokyo?"}],
)
tool_call = resp.choices[0].message.tool_calls[0]
print(tool_call.function.name, tool_call.function.arguments)Tool / function schemas translate between OpenAI tools, Anthropic tools, and Gemini function_declarations automatically.
Errors
HTTP status codes
| Status | Meaning | Action |
|---|---|---|
| 401 | Invalid API key | Rotate via dashboard |
| 402 | Insufficient balance | Top up account |
| 403 | Model not allowed for this key | Check key permissions |
| 429 | Rate limit | Back off; raise tier or quota |
| 500/502/503 | Upstream provider error | Auto-retried; will failover |
| 524 | Stream timeout | Lower max_tokens or retry |
Privacy
Zero content retention by default
Planet AI does not store request bodies, response bodies, prompts, or generated content for routine traffic. Logs retain metadata only (request id, model, tokens, latency, status). You can opt in per-key to forward full traces to your own Langfuse / Datadog instance.
Get started