Skip to main content

Interfaces and Capabilities

The interfaces listed in this document are located at https://api.ourzai.com/v1/ and support both OpenAI and Anthropic compatible formats. See API Quick Start for authentication details.

Which Interfaces Can a Model Use?​

Different models support different interfaces: a chat model cannot generate images, and a video generation model cannot chat. The console's Pricing page indicates which interfaces each model supports, so confirm this before making a call. Using an interface that a model does not support, or calling a model that your account cannot use, will return a 404.

Authentication​

Pass your API key using one of the following methods:

  • Authorization: Bearer <YOUR_API_KEY> (recommended; use this for all OpenAI-compatible interfaces);
  • x-api-key: <YOUR_API_KEY> (the Anthropic SDK method);
  • x-goog-api-key: <YOUR_API_KEY> (can also be used to pass the key; this does not imply support for the native Gemini interface).

Do not place the key in URL query parameters (e.g., ?api_key=); such requests will be rejected.

Text​

Method and PathPurpose
POST /v1/chat/completionsChat completions, OpenAI-compatible, supports streaming via stream
POST /v1/responsesOpenAI Responses interface
POST /v1/messagesAnthropic Messages compatible
POST /v1/messages/count_tokensCalculate token count for Anthropic-formatted requests
POST /v1/embeddingsText vectors; supported by only some models
GET /v1/modelsModel list

Images​

Method and PathPurpose
POST /v1/images/generationsText-to-image, OpenAI-compatible
POST /v1/images/editsImage-to-image and image editing, OpenAI-compatible

Image interfaces return results synchronously.

Audio​

Method and PathPurpose
POST /v1/audio/speechText-to-speech, OpenAI-compatible
POST /v1/audio/transcriptionsSpeech-to-text, OpenAI-compatible

Responses may include X-Zai-Audio-Duration-Ms (audio duration in milliseconds) or X-Zai-Audio-Confidence (transcription confidence), depending on the model used.

Video Generation​

Video generation is asynchronous: first submit a task to receive a request_id, then poll the status, and download the result once the video is ready.

Method and PathPurpose
POST /v1/videos/generationsSubmit a video task; returns request_id
GET /v1/videos/generations/{request_id}Query task status
GET /v1/videos/generations/{request_id}/contentDownload the generated video

/v1/videos and /v1/videos/{request_id} are equivalent shorthand paths.

Submitting a Task​

Request body fields:

FieldDescription
modelRequired; the video model name
promptDescription of the visuals and motion
durationDuration (seconds)
aspect_ratioAspect ratio
resolutionResolution
generate_audioWhether to generate an audio track
seedRandom seed
watermarkWhether to add a watermark
imageFirst-frame image
last_frameLast-frame image
reference_imagesList of reference images
reference_audiosList of reference audio clips

The fields and values supported vary by model. Use the Pricing page to confirm the video interface and pricing; fill in the specific parameters according to the capabilities of the model you have selected. If parameter validation fails, the response may return a 400 with video_input_unsupported and indicate in field which fields need adjustment.

curl https://api.ourzai.com/v1/videos/generations \
-H "Authorization: Bearer $ZAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "<VIDEO_MODEL_ID>", "prompt": "Sunset by the sea, with a slow camera push-in", "duration": 5}'

Querying Status and Retrieving Results​

The query returns request_id and status. When the video is ready, it includes video.url (along with duration, resolution, etc.); on failure, it includes error.code and error.message. Possible values for status:

StatusMeaning
pendingGenerating; check back later
doneCompleted; ready to download
failedGeneration failed; see error
expiredTask expired

Downloading the Video​

After done, request /content to retrieve the video file. If the video is not ready yet, the request returns 409 video_not_ready; simply retry later.

Video generation is billed only once upon successful completion; polling any number of times does not incur additional charges.

Calling Gemini Models​

The native Gemini interface under /v1beta/ is not currently available. To call Gemini models, first check the Pricing page to confirm the compatible interface supported by the model, then use the corresponding /v1/ path.

Integrate by model​

Model catalog and integration — Choose a model to see its exposed endpoints and complete request examples. Use the exact model ID; models from the same provider do not necessarily support the same interfaces.