Router.Images.Generations
Create a Generation
Create an Imagefrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.router.images.generations.create(prompt="<value>", model="2", n=1, 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",
},
],
"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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.router.images.generations.create({
prompt: "<value>",
model: "2",
retry: {
onCodes: [
429,
500,
502,
503,
504,
],
},
cache: {
ttl: 3600,
type: "exact_match",
},
loadBalancer: {
type: "weight_based",
models: [],
},
timeout: {
callTimeout: 30000,
},
orq: {
retry: {
onCodes: [
429,
500,
502,
503,
504,
],
},
fallbacks: [
{
model: "openai/gpt-4o-mini",
},
],
identity: {
id: "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV",
displayName: "Jane Doe",
email: "jane.doe@example.com",
metadata: [
{
"department": "Engineering",
"role": "Senior Developer",
},
],
logoUrl: "https://example.com/avatars/jane-doe.jpg",
tags: [
"hr",
"engineering",
],
},
cache: {
ttl: 3600,
type: "exact_match",
},
loadBalancer: {
type: "weight_based",
models: [
{
model: "openai/gpt-4o",
weight: 0.7,
},
{
model: "anthropic/claude-3-5-sonnet",
weight: 0.3,
},
],
},
timeout: {
callTimeout: 30000,
},
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"prompt": str, # required
"model": str, # required
"background": OptionalNullable[Background],
"moderation": OptionalNullable[Moderation],
"n": OptionalNullable[int],
"output_compression": OptionalNullable[int],
"output_format": OptionalNullable[OutputFormat],
"quality": OptionalNullable[Quality],
"response_format": OptionalNullable[CreateImageResponseFormat],
"size": OptionalNullable[str],
"style": OptionalNullable[Style],
"metadata": Dict[str, str],
"name": Optional[str],
"fallbacks": { # optional
"model": str, # required
},
"retry": { # optional
"count": Optional[float],
"on_codes": List[float],
},
"cache": { # optional
"ttl": Optional[float],
"type": Literal["exact_match"], # required
},
"load_balancer": Union[CreateImageLoadBalancer1],
"timeout": { # optional
"call_timeout": float, # required
},
"plugins": Union[PIIRedactionPluginAuto, PIIRedactionPluginEn, PIIRedactionPluginNl],
"orq": { # optional
"name": Optional[str],
"retry": { # optional
"count": Optional[float],
"on_codes": List[float],
},
"fallbacks": { # optional
"model": str, # required
},
"identity": { # optional
"id": str, # required
"display_name": Optional[str],
"email": Optional[str],
"metadata": List[Dict[str, Any]],
"logo_url": Optional[str],
"tags": List[str],
},
"~~`contact`~~": { # optional
"id": str, # required
"display_name": Optional[str],
"email": Optional[str],
"metadata": List[Dict[str, Any]],
"logo_url": Optional[str],
"tags": List[str],
},
"cache": { # optional
"ttl": Optional[float],
"type": Literal["exact_match"], # required
},
"load_balancer": Union[CreateImageLoadBalancerRouterImagesGenerations1],
"timeout": { # optional
"call_timeout": float, # required
},
},
}
{
prompt: string; // required
background?: string;
model: string; // required
moderation?: string;
n?: number;
outputCompression?: number;
outputFormat?: string;
quality?: string;
responseFormat?: string;
size?: string;
style?: string;
metadata?: Record<string, string>;
name?: string;
fallbacks?: {
model: string; // required
};
retry?: {
count?: number;
onCodes?: number[];
};
cache?: {
ttl?: number;
type: string; // required
};
loadBalancer?: string;
timeout?: {
callTimeout: number; // required
};
plugins?: string;
orq?: {
name?: string;
retry?: {
count?: number;
onCodes?: number[];
};
fallbacks?: {
model: string; // required
};
identity?: {
id: string; // required
displayName?: string;
email?: string;
metadata?: Record<string, any>[];
logoUrl?: string;
tags?: string[];
};
~~`contact`~~?: {
id: string; // required
displayName?: string;
email?: string;
metadata?: Record<string, any>[];
logoUrl?: string;
tags?: string[];
};
cache?: {
ttl?: number;
type: string; // required
};
loadBalancer?: string;
timeout?: {
callTimeout: number; // required
};
};
}
Show Response
Show Response
{
"created": float,
"data": {
"revised_prompt": OptionalNullable[str],
"b64_json": Optional[str],
"url": Optional[str],
},
"usage": { # optional
"input_tokens": Optional[float],
"input_tokens_details": {
"image_tokens": Optional[float],
"text_tokens": Optional[float],
},
"output_tokens": Optional[float],
"total_tokens": Optional[float],
},
}
{
created: number;
data: {
revisedPrompt?: string;
b64Json?: string;
url?: string;
};
usage?: {
inputTokens?: number;
inputTokensDetails: {
imageTokens?: number;
textTokens?: number;
};
outputTokens?: number;
totalTokens?: number;
};
}