GET STARTED

Your first API call.

Use the OpenAI SDK you already know. Change the base URL, API key and model.

This preview runs non-streaming sandbox text requests. The example domain is a placeholder. Use the current Site origin followed by /v1 for authenticated sandbox testing. External API access requires an independent API domain and production setup.

  1. Create an account
  2. Add test balance
  3. Create a test key
  4. Install the SDK and send your first request.
quickstart
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="YOUR_API_KEY",
5 base_url="https://api.example.com/v1"
6)
7
8response = client.chat.completions.create(
9 model="gpt-4.1-mini",
10 messages=[{
11 "role": "user",
12 "content": "Build something extraordinary."
13 }]
14)
15print(response.choices[0].message.content)
OpenAI-compatible. Familiar by design.REST API

Authentication

Send your API key in the Authorization header. Keys are shown once and stored as hashes. Keep them in a server environment variable; do not put keys in browser code or source control.

Authorization: Bearer YOUR_API_KEY

Test keys start with tk_test_. The sandbox rate limit is 30 requests per minute per key.

Model routing

Use a model ID from the catalog. API keys can be restricted to a subset of models. The sandbox uses the first listed route tier and only accepts models with verified input and output rates.

claude-sonnet-5gpt-4.1-minigemini-3.5-flash-liteclaude-opus-5

API reference

POST /v1/chat/completions

FieldTypeDescription
modelstringRequired. Public model ID.
messagesarrayRequired. 1–50 messages with role and text content.
route_tierstringOptional: Economy, Standard or Premium when listed for the model.
streambooleanfalse only in sandbox.
{
  "object": "chat.completion",
  "choices": [{"message": {"role": "assistant", "content": "..."}}],
  "usage": {"prompt_tokens": 24, "completion_tokens": 18, "total_tokens": 42},
  "sandbox": true
}

Usage & billing

Text charges = input tokens × input rate / 1,000,000 + output tokens × output rate / 1,000,000. Image and video dimensions are quoted separately. Sandbox responses use fixed test usage (24 input / 18 output tokens), regardless of prompt length. Charges round up to one micro-dollar.

The server checks your balance, model permissions and daily/monthly key limits before recording a charge. Logs contain request metadata, not full prompts or responses.

Errors & limits

400Invalid model, message format or unsupported streaming.
401Missing or invalid key, or sign-in required.
403Model restricted, access denied or invalid request origin.
413Request exceeds 20,000 characters.
429Balance, spend limit, rate limit or shared daily AI allowance reached. Daily AI allowance resets at 00:00 Beijing time.
503Service unavailable. Retry with exponential backoff.

Checking today’s AI allowance…

100 requests/day across Advisor and Playground/API. One submission = one request; admitted attempts count even if they fail. Resets at 00:00 Beijing time. Browsing and cost estimates do not count.

Try a sandbox request

A small test charge is deducted from test balance. Your key is used only for this request and is not saved in your browser.