/images/generations
Overview
| Feature | Supported | Notes |
|---|---|---|
| Cost Tracking | ✅ | Works with all supported models |
| Logging | ✅ | Works across all integrations |
| Fallbacks | ✅ | Works between supported models |
| Loadbalancing | ✅ | Works between supported models |
| Supported Providers | OpenAI, 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 toopenai/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,lowfor gpt-image-1hd,standardfor dall-e-3
response_format: string - The format in which images are returned. Must beurlorb64_json.size: string - The size of the generated images.- For gpt-image-1:
1024x1024,1536x1024,1024x1536, orauto - For dall-e-3:
1024x1024,1792x1024, or1024x1792 - For dall-e-2:
256x256,512x512, or1024x1024
- For gpt-image-1:
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
| Provider | Documentation Link |
|---|---|
| OpenAI | OpenAI Image Generation |
| Azure OpenAI | Azure OpenAI Image Generation |
| Google AI Studio | Google AI Studio Image Generation |
| Vertex AI | Vertex AI Image Generation |
| AWS Bedrock | Bedrock Image Generation |
| Recraft | Recraft Image Generation |