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.
- Create an account
- Add test balance
- Create a test key
- Install the SDK and send your first request.
1from openai import OpenAI23client = OpenAI(4api_key="YOUR_API_KEY",5base_url="https://api.example.com/v1"6)78response = client.chat.completions.create(9model="gpt-4.1-mini",10messages=[{11"role": "user",12"content": "Build something extraordinary."13}]14)15print(response.choices[0].message.content)
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-5API reference
POST /v1/chat/completions
| Field | Type | Description |
|---|---|---|
| model | string | Required. Public model ID. |
| messages | array | Required. 1–50 messages with role and text content. |
| route_tier | string | Optional: Economy, Standard or Premium when listed for the model. |
| stream | boolean | false 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
400 | Invalid model, message format or unsupported streaming. |
401 | Missing or invalid key, or sign-in required. |
403 | Model restricted, access denied or invalid request origin. |
413 | Request exceeds 20,000 characters. |
429 | Balance, spend limit, rate limit or shared daily AI allowance reached. Daily AI allowance resets at 00:00 Beijing time. |
503 | Service 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.