- create - Create image variation
Create an Image Variation
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.router.images.variations.create(model="Altima", n=1, response_format="url", size="1024x1024", retry={
"on_codes": [
429,
500,
502,
503,
504,
],
}, cache={
"ttl": 3600,
"type": "exact_match",
}, load_balancer={
"type": "weight_based",
"models": [],
}, timeout={
"call_timeout": 30000,
}, orq={
"retry": {
"on_codes": [
429,
500,
502,
503,
504,
],
},
"fallbacks": [
{
"model": "openai/gpt-4o-mini",
},
],
"prompt": {
"id": "prompt_01ARZ3NDEKTSV4RRFFQ69G5FAV",
"version": "latest",
},
"identity": {
"id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV",
"display_name": "Jane Doe",
"email": "jane.doe@example.com",
"metadata": [
{
"department": "Engineering",
"role": "Senior Developer",
},
],
"logo_url": "https://example.com/avatars/jane-doe.jpg",
"tags": [
"hr",
"engineering",
],
},
"cache": {
"ttl": 3600,
"type": "exact_match",
},
"load_balancer": {
"type": "weight_based",
"models": [
{
"model": "openai/gpt-4o",
"weight": 0.7,
},
{
"model": "anthropic/claude-3-5-sonnet",
"weight": 0.3,
},
],
},
"timeout": {
"call_timeout": 30000,
},
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
model |
str | ✔️ | The model to use for image generation. |
image |
Optional[Any] | ➖ | The image to edit. Must be a supported image file. It should be a png, webp, or jpg file less than 50MB. |
n |
OptionalNullable[float] | ➖ | The number of images to generate. Must be between 1 and 10. |
response_format |
Optional[models.CreateImageVariationResponseFormat] | ➖ | The format in which the generated images are returned. Must be one of url or b64_json. URLs are only valid for 60 minutes after the image has been generated. |
size |
Optional[models.Size] | ➖ | The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. |
user |
Optional[str] | ➖ | A unique identifier representing your end-user, which can help to monitor and detect abuse. |
name |
Optional[str] | ➖ | The name to display on the trace. If not specified, the default system name will be used. |
fallbacks |
List[models.CreateImageVariationFallbacks] | ➖ | Array of fallback models to use if primary model fails |
retry |
Optional[models.CreateImageVariationRetry] | ➖ | Retry configuration for the request |
cache |
Optional[models.CreateImageVariationCache] | ➖ | Cache configuration for the request. |
load_balancer |
Optional[models.CreateImageVariationLoadBalancer] | ➖ | Load balancer configuration for the request. |
timeout |
Optional[models.CreateImageVariationTimeout] | ➖ | Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured. |
orq |
Optional[models.CreateImageVariationOrq] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.CreateImageVariationResponseBody
| Error Type | Status Code | Content Type |
|---|---|---|
| models.APIError | 4XX, 5XX | */* |