← Back to docs

Images, audio and video

Check formats and job lifecycles.

Check each model before sending images, audio or video. For asynchronous video, retain the job ID and poll its status; do not recreate jobs automatically after a disrupted response.

Vision

Models labeled Vision accept PNG/JPEG/WebP/GIF images. For Claude via Anthropic Messages, send a base64 image in the same content array as your question:

curl https://thapi.cloud/v1/messages \
  -H "x-api-key: ${API_KEY:?API_KEY}" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-fable-5",
    "max_tokens": 512,
    "messages": [{
      "role": "user",
      "content": [
        {
          "type": "image",
          "source": {
            "type": "base64",
            "media_type": "image/png",
            "data": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAXElEQVR4nO3PIREAIBAAsI+DQaPJhKbVF0JTggiIt7tbgcUds6LlKur7VISAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwM8D31WVS4B9/IAAAAAASUVORK5CYII="
          }
        },
        {"type": "text", "text": "Describe the content of this photo"}
      ]
    }]
  }'

22 GPT models use the native OpenAI image_url format at /v1/chat/completions. The gateway supports both base64 data URLs and http(s) image URLs:

{
  "model": "gpt-5.6-sol",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Read this photo content"},
      {
        "type": "image_url",
        "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAXElEQVR4nO3PIREAIBAAsI+DQaPJhKbVF0JTggiIt7tbgcUds6LlKur7VISAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwM8D31WVS4B9/IAAAAAASUVORK5CYII="}
      }
    ]
  }]
}

Image tokens returned by the provider will be recorded and charged as input tokens. It is recommended to compress images before sending and keep the entire request content under the 2047 MB limit.

Images, audio and video

Generate and edit images

JSON guides for image generation, references, results and pricing.

View the full guide

/v1/images/generations

curl --fail-with-body --show-error https://thapi.cloud/v1/images/generations \
  -H "Authorization: Bearer ${STALI_API_KEY:?STALI_API_KEY}" \
  -H "content-type: application/json" \
  -d '{
    "model": "req/gpt-image-2",
    "prompt": "a tiny red circle on white",
    "size": "1024x1024",
    "n": 1
  }'

/v1/images/edits

curl --fail-with-body --show-error https://thapi.cloud/v1/images/edits \
  -H "Authorization: Bearer ${STALI_API_KEY:?STALI_API_KEY}" \
  -H "content-type: application/json" \
  -d '{
    "model": "req/gpt-image-2",
    "prompt": "keep the same subject, soft studio lighting",
    "image": "https://example.com/reference.png",
    "size": "1024x1024",
    "n": 1
  }'

# image / image_url / reference_image / ref_image:
# data URL, base64 thuần, hoặc URL http(s) công khai
Create video

Snippets are protocol-verified; run a small test call and verify the Usage log before deploying to production.