Skip to main content
POST
/
generate
/
image
Generate Image ⚠️
curl --request POST \
  --url https://api.animusai.co/v2/generate/image \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "prompt": "A woman checking her phone"
}'
{
  "output": [
    "https://somesite.com/image.png"
  ]
}
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

ParameterTypeRequiredDescription
promptstringYesThe text prompt describing the image to generate

Example Request

{
  "prompt": "A woman checking her phone"
}

Response

The response contains an array of generated image URLs.
{
  "output": [
    "https://somesite.com/image.png"
  ]
}

Response Fields

FieldTypeDescription
outputarrayArray containing the generated image URL(s)

Usage Examples

cURL

curl https://api.animusai.co/v2/generate/image \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ANIMUS_API_KEY" \
  -d '{
    "prompt": "A serene mountain landscape at sunset"
  }'

JavaScript

const response = await fetch('https://api.animusai.co/v2/generate/image', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${process.env.ANIMUS_API_KEY}`
  },
  body: JSON.stringify({
    prompt: "A futuristic city with flying cars"
  })
});

const data = await response.json();
console.log('Generated image URL:', data.output[0]);

Python

import requests
import os

url = "https://api.animusai.co/v2/generate/image"
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {os.getenv('ANIMUS_API_KEY')}"
}

payload = {
    "prompt": "A robot painting a masterpiece"
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()
print(f"Generated image URL: {data['output'][0]}")

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 prompt
  • 401 Unauthorized: Invalid or missing API key
  • 429 Too Many Requests: Rate limit exceeded
  • 500 Internal Server Error: Image generation service error
  • Chat Completions - Can automatically generate image prompts when check_image_generation is enabled
  • Media Completions - For analyzing generated images with vision models

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
prompt
string
required

The text prompt describing the image to generate

Example:

"A woman checking her phone"

Response

200 - application/json

Successfully generated image

output
string<uri>[]
required

Array containing the generated image URL(s)

URL of the generated image

Example:
["https://somesite.com/image.png"]
I