Model APIs
Vision input and image generation
Distinguish vision understanding from generation, using image_url content parts and images/generations.
Updated
/v1/images/generationsUnderstand an image
Vision understanding uses a vision-capable chat model. Chat Completions content can include text and image_url parts. The URL must be reachable by the serving path; a local file path is not a remote image URL. Provide temporary access to private resources according to your application’s data policy.
{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image."
},
{
"type": "image_url",
"image_url": {
"url": "https://your-domain.example/image.png"
}
}
]
}
]
}Generate an image
POST /v1/images/generations requires an image-generation model. model and prompt are the core fields; size, count, quality and response-format support depend on that model. Start with a minimal request and add verified parameters. OpenAI compatibility alone does not guarantee every image feature.
curl --fail-with-body https://api.token4ai.cloud/v1/images/generations \
-H "Authorization: Bearer $TOKEN4AI_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "YOUR_MODEL_ID",
"prompt": "A clean technical illustration of a cloud API gateway."
}'Handle outputs and limits
Read image URLs or Base64 data from the actual response. Check MIME type and size before saving; provider URLs may expire. Input size, image count and output dimensions depend on model, route and deployment limits. For a 413, reduce the payload before retrying.