AI Image Generation (/api/ai/image)
Try it
AI Image Generation
Generate images using Azure OpenAI (DALL·E) with fallback to Vercel AI Gateway.
Endpoint
POST /api/ai/imageRequest Body
| Field | Type | Description | Required |
|---|---|---|---|
| prompt | string | Text prompt to generate the image | Yes |
| provider | ’azure’ | ‘vercel’ | Provider to use | No (default: ‘azure’) |
| size | ’256x256’ | ‘512x512’ | ‘1024x1024’ | Output size | No (default: ‘1024x1024’) |
| n | number | Number of images to generate | No (default: 1) |
| quality | ’standard’ | ‘hd’ | Quality level (Azure) | No |
Example (Azure)
{
"prompt": "a watercolor fox in a forest",
"provider": "azure",
"size": "1024x1024",
"n": 1,
"quality": "hd"
}Example (Vercel fallback)
{
"prompt": "a watercolor fox in a forest",
"provider": "vercel"
}Response
{
"provider": "azure",
"images": [ { "url": "..." } ]
}Environment
- Azure:
AZURE_OPENAI_ENDPOINT,AZURE_OPENAI_API_KEY,AZURE_OPENAI_IMAGES_DEPLOYMENT - Vercel fallback:
VERCEL_AI_GATEWAY_OPENAI,VERCEL_AI_GATEWAY_API_KEY
Last updated on