API Quickstart and integration guide
Use one API Key for text, images, and video. Examples below use this website as the API endpoint.
Authentication and models
Create and save a Key in the console, then send it in the Authorization: Bearer header. Keep the key on your server.
Replace MODEL_ID with a published model ID. Supported protocols, duration, resolution, and prices depend on that model.
Text
POST /v1/chat/completions
Images
POST /v1/images/tasks
Video
POST /v1/videos/tasks
Python and Node.js Quickstart
Set API_STATION_KEY in your server environment. These examples use the same text endpoint as curl.
Models, specifications and billing units
Text rates are shown per one million input or output tokens. Images are billed per image, and video rates per generated second. The model and specification determine the rate; check the live catalog before submitting.
The examples use published specifications: gpt-image-2 at 1K, and grok-imagine-video-1.5 at 480p for 8 seconds. Do not assume other sizes, durations, tools or media inputs are supported.
You can list models available to your key with GET /v1/models. The public model catalog shows specifications and prices; key permissions may restrict the list.
A media task returns HTTP 201 with id, state and billing_state. Poll GET /v1/tasks/{id} with the same API Key. Treat succeeded as a generation result and settled as a separate billing result. If submission is uncertain, keep the same Idempotency-Key and input.
Task status and results
For each image or video operation, choose a unique 16–128 character Idempotency-Key. Retry an uncertain submission with the same key and the same input.
Save the id returned by task creation and query its status with the same API Key. After state is succeeded, read results[].url and check billing_state separately.
GET /v1/tasks/{id}
Read results[].url and results[].expires_at when available. Result links are temporary; save files you need to keep. Querying the same task refreshes the site access link without creating another generation. An upstream result may still expire.
Troubleshooting requests
- 401 / 403
- Check the API Key status and its model permissions.
- 400
- Check the model ID and the supported input specification.
- 402
- The available balance is insufficient for this request.
- 409
- Use the original Idempotency-Key with identical input, or create a new key for a different operation.
- 429
- Wait for the Retry-After interval before retrying.
- 503
- The service may be paused or not configured. Check availability with the administrator.
Keep the X-Oneapi-Request-Id response header when reporting a problem. Never include your API Key, password or verification code.
Do not automatically retry after a text stream has started. Keep the request ID and check your usage records if the connection is interrupted.
View usage