Skip to content

Image Generation

This page demonstrates an Images Generate–style API reference.

Create an image

POST /v1/images/generations

bash
curl https://api.example.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "image-1",
    "prompt": "A minimal neon cyberpunk logo, dark background, soft glow"
  }'

TypeScript example

ts
type ImageGenerationRequest = {
  model: string
  prompt: string
  size?: '1024x1024' | '1024x1536' | '1536x1024'
}

export async function generateImage(apiKey: string, req: ImageGenerationRequest) {
  const res = await fetch('https://api.example.com/v1/images/generations', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${apiKey}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(req)
  })

  if (!res.ok) throw new Error(await res.text())
  return res.json()
}

Response format (example)

json
{
  "created": 1710000000,
  "data": [
    { "url": "https://cdn.example.com/images/xxxx.png" }
  ]
}