Skip to main content

/images/generations

Overview

FeatureSupportedNotes
Cost TrackingWorks with all supported models
LoggingWorks across all integrations
FallbacksWorks between supported models
LoadbalancingWorks between supported models
Supported ProvidersOpenAI, Azure, Google AI Studio, Vertex AI, AWS Bedrock, Recraft

Quick Start

Python

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.images.generate(
model="openai/dall-e-3",
prompt="A cute baby sea otter",
n=1,
size="1024x1024"
)

print(response.data[0].url)

cURL

curl https://api.haimaker.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "openai/dall-e-3",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}'

Using Different Models

OpenAI DALL-E 3

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.images.generate(
model="openai/dall-e-3",
prompt="A beautiful sunset over mountains",
n=1,
size="1024x1024",
quality="hd" # Options: standard, hd
)

print(response.data[0].url)

OpenAI GPT-Image-1

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.images.generate(
model="openai/gpt-image-1",
prompt="A futuristic cityscape at night",
n=1,
size="1024x1024",
quality="high" # Options: auto, high, medium, low
)

print(response.data[0].url)

Bedrock Stable Diffusion

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.images.generate(
model="bedrock/stability.stable-diffusion-xl-v0",
prompt="A fantasy landscape with dragons",
n=1,
size="1024x1024"
)

print(response.data[0].url)

Vertex AI

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.images.generate(
model="vertex_ai/imagegeneration@006",
prompt="An olympic size swimming pool",
n=1,
size="1024x1024"
)

print(response.data[0].url)

Input Parameters

Required Fields

  • prompt: string - A text description of the desired image(s).

Optional Fields

  • model: string - The model to use for image generation. Defaults to openai/dall-e-3.
  • n: int - The number of images to generate. Must be between 1 and 10. For dall-e-3, only n=1 is supported.
  • quality: string - The quality of the image that will be generated.
    • auto (default for gpt-image-1)
    • high, medium, low for gpt-image-1
    • hd, standard for dall-e-3
  • response_format: string - The format in which images are returned. Must be url or b64_json.
  • size: string - The size of the generated images.
    • For gpt-image-1: 1024x1024, 1536x1024, 1024x1536, or auto
    • For dall-e-3: 1024x1024, 1792x1024, or 1024x1792
    • For dall-e-2: 256x256, 512x512, or 1024x1024
  • style: string - The style of the generated images (dall-e-3 only). Options: vivid, natural.
  • user: string - A unique identifier representing your end-user.

Output Format

{
"created": 1703658209,
"data": [{
"b64_json": null,
"revised_prompt": "Adorable baby sea otter with a coat of thick brown fur...",
"url": "https://..."
}],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}

Supported Providers

ProviderDocumentation Link
OpenAIOpenAI Image Generation
Azure OpenAIAzure OpenAI Image Generation
Google AI StudioGoogle AI Studio Image Generation
Vertex AIVertex AI Image Generation
AWS BedrockBedrock Image Generation
RecraftRecraft Image Generation