Alpha Feature: This endpoint is currently in alpha state and not recommended for production use. The API and functionality may change without notice.
Overview
Generates an image from a text prompt using an image generation model. This endpoint takes a descriptive text prompt and returns a URL to the generated image.Request Body
Parameter | Type | Required | Description |
---|---|---|---|
prompt | string | Yes | The text prompt describing the image to generate |
Example Request
Response
The response contains an array of generated image URLs.Response Fields
Field | Type | Description |
---|---|---|
output | array | Array containing the generated image URL(s) |
Usage Examples
cURL
JavaScript
Python
Best Practices
- Be descriptive: More detailed prompts generally produce better results
- Specify style: Include artistic style, mood, or technical details for better control
- Consider composition: Mention lighting, perspective, or framing for enhanced results
Error Handling
The endpoint returns standard HTTP status codes. Common error responses include:400 Bad Request
: Invalid or missing prompt401 Unauthorized
: Invalid or missing API key429 Too Many Requests
: Rate limit exceeded500 Internal Server Error
: Image generation service error
Related Endpoints
- Chat Completions - Can automatically generate image prompts when
check_image_generation
is enabled - Media Completions - For analyzing generated images with vision models
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
The text prompt describing the image to generate
Example:
"A woman checking her phone"
Response
200 - application/json
Successfully generated image
Array containing the generated image URL(s)
URL of the generated image
Example:
["https://somesite.com/image.png"]