"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations from .contentpartimage import ContentPartImage, ContentPartImageTypedDict from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr import pydantic from pydantic import model_serializer from typing import Any, Dict, List, Literal, Optional, Union from typing_extensions import Annotated, NotRequired, TypedDict ImageGenerationRequestAspectRatio = Union[ Literal[ "1:1", "1:2", "1:4", "1:8", "2:1", "2:3", "3:2", "3:4", "4:1", "4:3", "4:5", "5:4", "8:1", "9:16", "16:9", "9:19.5", "19.5:9", "9:20", "20:9", "9:21", "21:9", "auto", ], UnrecognizedStr, ] r"""Normalized aspect ratio of the generated image. Providers clamp to their supported subset.""" ImageGenerationRequestBackground = Union[ Literal[ "auto", "transparent", "opaque", ], UnrecognizedStr, ] r"""Background treatment. `transparent` requires an output_format that supports alpha (png or webp).""" ImageGenerationRequestOutputFormat = Union[ Literal[ "png", "jpeg", "webp", "svg", ], UnrecognizedStr, ] r"""Encoding of the returned image bytes. Most models produce raster formats (png, jpeg, webp). SVG is supported by vectorization models (e.g. Quiver) — the SVG markup is UTF-8 base64-encoded in `b64_json`.""" class ImageGenerationRequestOptionsTypedDict(TypedDict): r"""Provider-specific options keyed by provider slug. Only options for the matched provider are forwarded; the rest are ignored. Unrecognized keys are silently dropped.""" oneai: NotRequired[Dict[str, Nullable[Any]]] ai21: NotRequired[Dict[str, Nullable[Any]]] aion_labs: NotRequired[Dict[str, Nullable[Any]]] akashml: NotRequired[Dict[str, Nullable[Any]]] alibaba: NotRequired[Dict[str, Nullable[Any]]] amazon_bedrock: NotRequired[Dict[str, Nullable[Any]]] amazon_nova: NotRequired[Dict[str, Nullable[Any]]] ambient: NotRequired[Dict[str, Nullable[Any]]] anthropic: NotRequired[Dict[str, Nullable[Any]]] anyscale: NotRequired[Dict[str, Nullable[Any]]] arcee_ai: NotRequired[Dict[str, Nullable[Any]]] atlas_cloud: NotRequired[Dict[str, Nullable[Any]]] atoma: NotRequired[Dict[str, Nullable[Any]]] avian: NotRequired[Dict[str, Nullable[Any]]] azure: NotRequired[Dict[str, Nullable[Any]]] baidu: NotRequired[Dict[str, Nullable[Any]]] baseten: NotRequired[Dict[str, Nullable[Any]]] black_forest_labs: NotRequired[Dict[str, Nullable[Any]]] byteplus: NotRequired[Dict[str, Nullable[Any]]] centml: NotRequired[Dict[str, Nullable[Any]]] cerebras: NotRequired[Dict[str, Nullable[Any]]] chutes: NotRequired[Dict[str, Nullable[Any]]] cirrascale: NotRequired[Dict[str, Nullable[Any]]] clarifai: NotRequired[Dict[str, Nullable[Any]]] cloudflare: NotRequired[Dict[str, Nullable[Any]]] cohere: NotRequired[Dict[str, Nullable[Any]]] crofai: NotRequired[Dict[str, Nullable[Any]]] crucible: NotRequired[Dict[str, Nullable[Any]]] crusoe: NotRequired[Dict[str, Nullable[Any]]] darkbloom: NotRequired[Dict[str, Nullable[Any]]] decart: NotRequired[Dict[str, Nullable[Any]]] deepinfra: NotRequired[Dict[str, Nullable[Any]]] deepseek: NotRequired[Dict[str, Nullable[Any]]] dekallm: NotRequired[Dict[str, Nullable[Any]]] digitalocean: NotRequired[Dict[str, Nullable[Any]]] enfer: NotRequired[Dict[str, Nullable[Any]]] fake_provider: NotRequired[Dict[str, Nullable[Any]]] featherless: NotRequired[Dict[str, Nullable[Any]]] fireworks: NotRequired[Dict[str, Nullable[Any]]] friendli: NotRequired[Dict[str, Nullable[Any]]] gmicloud: NotRequired[Dict[str, Nullable[Any]]] google_ai_studio: NotRequired[Dict[str, Nullable[Any]]] google_vertex: NotRequired[Dict[str, Nullable[Any]]] gopomelo: NotRequired[Dict[str, Nullable[Any]]] groq: NotRequired[Dict[str, Nullable[Any]]] heygen: NotRequired[Dict[str, Nullable[Any]]] huggingface: NotRequired[Dict[str, Nullable[Any]]] hyperbolic: NotRequired[Dict[str, Nullable[Any]]] hyperbolic_quantized: NotRequired[Dict[str, Nullable[Any]]] inception: NotRequired[Dict[str, Nullable[Any]]] inceptron: NotRequired[Dict[str, Nullable[Any]]] inferact_vllm: NotRequired[Dict[str, Nullable[Any]]] inference_net: NotRequired[Dict[str, Nullable[Any]]] infermatic: NotRequired[Dict[str, Nullable[Any]]] inflection: NotRequired[Dict[str, Nullable[Any]]] inocloud: NotRequired[Dict[str, Nullable[Any]]] io_net: NotRequired[Dict[str, Nullable[Any]]] ionstream: NotRequired[Dict[str, Nullable[Any]]] klusterai: NotRequired[Dict[str, Nullable[Any]]] lambda_: NotRequired[Dict[str, Nullable[Any]]] lepton: NotRequired[Dict[str, Nullable[Any]]] liquid: NotRequired[Dict[str, Nullable[Any]]] lynn: NotRequired[Dict[str, Nullable[Any]]] lynn_private: NotRequired[Dict[str, Nullable[Any]]] mancer: NotRequired[Dict[str, Nullable[Any]]] mancer_old: NotRequired[Dict[str, Nullable[Any]]] mara: NotRequired[Dict[str, Nullable[Any]]] meta: NotRequired[Dict[str, Nullable[Any]]] minimax: NotRequired[Dict[str, Nullable[Any]]] mistral: NotRequired[Dict[str, Nullable[Any]]] modal: NotRequired[Dict[str, Nullable[Any]]] modelrun: NotRequired[Dict[str, Nullable[Any]]] modular: NotRequired[Dict[str, Nullable[Any]]] moonshotai: NotRequired[Dict[str, Nullable[Any]]] morph: NotRequired[Dict[str, Nullable[Any]]] ncompass: NotRequired[Dict[str, Nullable[Any]]] nebius: NotRequired[Dict[str, Nullable[Any]]] nex_agi: NotRequired[Dict[str, Nullable[Any]]] nextbit: NotRequired[Dict[str, Nullable[Any]]] nineteen: NotRequired[Dict[str, Nullable[Any]]] novita: NotRequired[Dict[str, Nullable[Any]]] nvidia: NotRequired[Dict[str, Nullable[Any]]] octoai: NotRequired[Dict[str, Nullable[Any]]] open_inference: NotRequired[Dict[str, Nullable[Any]]] openai: NotRequired[Dict[str, Nullable[Any]]] parasail: NotRequired[Dict[str, Nullable[Any]]] perceptron: NotRequired[Dict[str, Nullable[Any]]] perplexity: NotRequired[Dict[str, Nullable[Any]]] phala: NotRequired[Dict[str, Nullable[Any]]] poolside: NotRequired[Dict[str, Nullable[Any]]] quiver: NotRequired[Dict[str, Nullable[Any]]] recraft: NotRequired[Dict[str, Nullable[Any]]] recursal: NotRequired[Dict[str, Nullable[Any]]] reflection: NotRequired[Dict[str, Nullable[Any]]] reka: NotRequired[Dict[str, Nullable[Any]]] relace: NotRequired[Dict[str, Nullable[Any]]] replicate: NotRequired[Dict[str, Nullable[Any]]] sakana_ai: NotRequired[Dict[str, Nullable[Any]]] sambanova: NotRequired[Dict[str, Nullable[Any]]] sambanova_cloaked: NotRequired[Dict[str, Nullable[Any]]] seed: NotRequired[Dict[str, Nullable[Any]]] sf_compute: NotRequired[Dict[str, Nullable[Any]]] siliconflow: NotRequired[Dict[str, Nullable[Any]]] sourceful: NotRequired[Dict[str, Nullable[Any]]] stealth: NotRequired[Dict[str, Nullable[Any]]] stepfun: NotRequired[Dict[str, Nullable[Any]]] streamlake: NotRequired[Dict[str, Nullable[Any]]] switchpoint: NotRequired[Dict[str, Nullable[Any]]] targon: NotRequired[Dict[str, Nullable[Any]]] tenstorrent: NotRequired[Dict[str, Nullable[Any]]] together: NotRequired[Dict[str, Nullable[Any]]] together_lite: NotRequired[Dict[str, Nullable[Any]]] ubicloud: NotRequired[Dict[str, Nullable[Any]]] upstage: NotRequired[Dict[str, Nullable[Any]]] venice: NotRequired[Dict[str, Nullable[Any]]] wafer: NotRequired[Dict[str, Nullable[Any]]] wandb: NotRequired[Dict[str, Nullable[Any]]] xai: NotRequired[Dict[str, Nullable[Any]]] xiaomi: NotRequired[Dict[str, Nullable[Any]]] z_ai: NotRequired[Dict[str, Nullable[Any]]] class ImageGenerationRequestOptions(BaseModel): r"""Provider-specific options keyed by provider slug. Only options for the matched provider are forwarded; the rest are ignored. Unrecognized keys are silently dropped.""" oneai: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="01ai") ] = None ai21: Optional[Dict[str, Nullable[Any]]] = None aion_labs: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="aion-labs") ] = None akashml: Optional[Dict[str, Nullable[Any]]] = None alibaba: Optional[Dict[str, Nullable[Any]]] = None amazon_bedrock: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="amazon-bedrock") ] = None amazon_nova: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="amazon-nova") ] = None ambient: Optional[Dict[str, Nullable[Any]]] = None anthropic: Optional[Dict[str, Nullable[Any]]] = None anyscale: Optional[Dict[str, Nullable[Any]]] = None arcee_ai: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="arcee-ai") ] = None atlas_cloud: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="atlas-cloud") ] = None atoma: Optional[Dict[str, Nullable[Any]]] = None avian: Optional[Dict[str, Nullable[Any]]] = None azure: Optional[Dict[str, Nullable[Any]]] = None baidu: Optional[Dict[str, Nullable[Any]]] = None baseten: Optional[Dict[str, Nullable[Any]]] = None black_forest_labs: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="black-forest-labs") ] = None byteplus: Optional[Dict[str, Nullable[Any]]] = None centml: Optional[Dict[str, Nullable[Any]]] = None cerebras: Optional[Dict[str, Nullable[Any]]] = None chutes: Optional[Dict[str, Nullable[Any]]] = None cirrascale: Optional[Dict[str, Nullable[Any]]] = None clarifai: Optional[Dict[str, Nullable[Any]]] = None cloudflare: Optional[Dict[str, Nullable[Any]]] = None cohere: Optional[Dict[str, Nullable[Any]]] = None crofai: Optional[Dict[str, Nullable[Any]]] = None crucible: Optional[Dict[str, Nullable[Any]]] = None crusoe: Optional[Dict[str, Nullable[Any]]] = None darkbloom: Optional[Dict[str, Nullable[Any]]] = None decart: Optional[Dict[str, Nullable[Any]]] = None deepinfra: Optional[Dict[str, Nullable[Any]]] = None deepseek: Optional[Dict[str, Nullable[Any]]] = None dekallm: Optional[Dict[str, Nullable[Any]]] = None digitalocean: Optional[Dict[str, Nullable[Any]]] = None enfer: Optional[Dict[str, Nullable[Any]]] = None fake_provider: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="fake-provider") ] = None featherless: Optional[Dict[str, Nullable[Any]]] = None fireworks: Optional[Dict[str, Nullable[Any]]] = None friendli: Optional[Dict[str, Nullable[Any]]] = None gmicloud: Optional[Dict[str, Nullable[Any]]] = None google_ai_studio: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="google-ai-studio") ] = None google_vertex: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="google-vertex") ] = None gopomelo: Optional[Dict[str, Nullable[Any]]] = None groq: Optional[Dict[str, Nullable[Any]]] = None heygen: Optional[Dict[str, Nullable[Any]]] = None huggingface: Optional[Dict[str, Nullable[Any]]] = None hyperbolic: Optional[Dict[str, Nullable[Any]]] = None hyperbolic_quantized: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="hyperbolic-quantized") ] = None inception: Optional[Dict[str, Nullable[Any]]] = None inceptron: Optional[Dict[str, Nullable[Any]]] = None inferact_vllm: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="inferact-vllm") ] = None inference_net: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="inference-net") ] = None infermatic: Optional[Dict[str, Nullable[Any]]] = None inflection: Optional[Dict[str, Nullable[Any]]] = None inocloud: Optional[Dict[str, Nullable[Any]]] = None io_net: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="io-net") ] = None ionstream: Optional[Dict[str, Nullable[Any]]] = None klusterai: Optional[Dict[str, Nullable[Any]]] = None lambda_: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="lambda") ] = None lepton: Optional[Dict[str, Nullable[Any]]] = None liquid: Optional[Dict[str, Nullable[Any]]] = None lynn: Optional[Dict[str, Nullable[Any]]] = None lynn_private: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="lynn-private") ] = None mancer: Optional[Dict[str, Nullable[Any]]] = None mancer_old: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="mancer-old") ] = None mara: Optional[Dict[str, Nullable[Any]]] = None meta: Optional[Dict[str, Nullable[Any]]] = None minimax: Optional[Dict[str, Nullable[Any]]] = None mistral: Optional[Dict[str, Nullable[Any]]] = None modal: Optional[Dict[str, Nullable[Any]]] = None modelrun: Optional[Dict[str, Nullable[Any]]] = None modular: Optional[Dict[str, Nullable[Any]]] = None moonshotai: Optional[Dict[str, Nullable[Any]]] = None morph: Optional[Dict[str, Nullable[Any]]] = None ncompass: Optional[Dict[str, Nullable[Any]]] = None nebius: Optional[Dict[str, Nullable[Any]]] = None nex_agi: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="nex-agi") ] = None nextbit: Optional[Dict[str, Nullable[Any]]] = None nineteen: Optional[Dict[str, Nullable[Any]]] = None novita: Optional[Dict[str, Nullable[Any]]] = None nvidia: Optional[Dict[str, Nullable[Any]]] = None octoai: Optional[Dict[str, Nullable[Any]]] = None open_inference: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="open-inference") ] = None openai: Optional[Dict[str, Nullable[Any]]] = None parasail: Optional[Dict[str, Nullable[Any]]] = None perceptron: Optional[Dict[str, Nullable[Any]]] = None perplexity: Optional[Dict[str, Nullable[Any]]] = None phala: Optional[Dict[str, Nullable[Any]]] = None poolside: Optional[Dict[str, Nullable[Any]]] = None quiver: Optional[Dict[str, Nullable[Any]]] = None recraft: Optional[Dict[str, Nullable[Any]]] = None recursal: Optional[Dict[str, Nullable[Any]]] = None reflection: Optional[Dict[str, Nullable[Any]]] = None reka: Optional[Dict[str, Nullable[Any]]] = None relace: Optional[Dict[str, Nullable[Any]]] = None replicate: Optional[Dict[str, Nullable[Any]]] = None sakana_ai: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="sakana-ai") ] = None sambanova: Optional[Dict[str, Nullable[Any]]] = None sambanova_cloaked: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="sambanova-cloaked") ] = None seed: Optional[Dict[str, Nullable[Any]]] = None sf_compute: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="sf-compute") ] = None siliconflow: Optional[Dict[str, Nullable[Any]]] = None sourceful: Optional[Dict[str, Nullable[Any]]] = None stealth: Optional[Dict[str, Nullable[Any]]] = None stepfun: Optional[Dict[str, Nullable[Any]]] = None streamlake: Optional[Dict[str, Nullable[Any]]] = None switchpoint: Optional[Dict[str, Nullable[Any]]] = None targon: Optional[Dict[str, Nullable[Any]]] = None tenstorrent: Optional[Dict[str, Nullable[Any]]] = None together: Optional[Dict[str, Nullable[Any]]] = None together_lite: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="together-lite") ] = None ubicloud: Optional[Dict[str, Nullable[Any]]] = None upstage: Optional[Dict[str, Nullable[Any]]] = None venice: Optional[Dict[str, Nullable[Any]]] = None wafer: Optional[Dict[str, Nullable[Any]]] = None wandb: Optional[Dict[str, Nullable[Any]]] = None xai: Optional[Dict[str, Nullable[Any]]] = None xiaomi: Optional[Dict[str, Nullable[Any]]] = None z_ai: Annotated[ Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="z-ai") ] = None @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ "01ai", "ai21", "aion-labs", "akashml", "alibaba", "amazon-bedrock", "amazon-nova", "ambient", "anthropic", "anyscale", "arcee-ai", "atlas-cloud", "atoma", "avian", "azure", "baidu", "baseten", "black-forest-labs", "byteplus", "centml", "cerebras", "chutes", "cirrascale", "clarifai", "cloudflare", "cohere", "crofai", "crucible", "crusoe", "darkbloom", "decart", "deepinfra", "deepseek", "dekallm", "digitalocean", "enfer", "fake-provider", "featherless", "fireworks", "friendli", "gmicloud", "google-ai-studio", "google-vertex", "gopomelo", "groq", "heygen", "huggingface", "hyperbolic", "hyperbolic-quantized", "inception", "inceptron", "inferact-vllm", "inference-net", "infermatic", "inflection", "inocloud", "io-net", "ionstream", "klusterai", "lambda", "lepton", "liquid", "lynn", "lynn-private", "mancer", "mancer-old", "mara", "meta", "minimax", "mistral", "modal", "modelrun", "modular", "moonshotai", "morph", "ncompass", "nebius", "nex-agi", "nextbit", "nineteen", "novita", "nvidia", "octoai", "open-inference", "openai", "parasail", "perceptron", "perplexity", "phala", "poolside", "quiver", "recraft", "recursal", "reflection", "reka", "relace", "replicate", "sakana-ai", "sambanova", "sambanova-cloaked", "seed", "sf-compute", "siliconflow", "sourceful", "stealth", "stepfun", "streamlake", "switchpoint", "targon", "tenstorrent", "together", "together-lite", "ubicloud", "upstage", "venice", "wafer", "wandb", "xai", "xiaomi", "z-ai", ] ) serialized = handler(self) m = {} for n, f in type(self).model_fields.items(): k = f.alias or n val = serialized.get(k, serialized.get(n)) if val != UNSET_SENTINEL: if val is not None or k not in optional_fields: m[k] = val return m class ImageGenerationRequestProviderTypedDict(TypedDict): r"""Provider-specific passthrough configuration""" options: NotRequired[ImageGenerationRequestOptionsTypedDict] class ImageGenerationRequestProvider(BaseModel): r"""Provider-specific passthrough configuration""" options: Optional[ImageGenerationRequestOptions] = None @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set(["options"]) serialized = handler(self) m = {} for n, f in type(self).model_fields.items(): k = f.alias or n val = serialized.get(k, serialized.get(n)) if val != UNSET_SENTINEL: if val is not None or k not in optional_fields: m[k] = val return m ImageGenerationRequestQuality = Union[ Literal[ "auto", "low", "medium", "high", ], UnrecognizedStr, ] r"""Rendering quality. Providers without a quality knob ignore this.""" ImageGenerationRequestResolution = Union[ Literal[ "512", "1K", "2K", "4K", ], UnrecognizedStr, ] r"""Normalized resolution tier of the generated image. Concrete pixel dimensions are derived per-provider.""" class ImageGenerationRequestTypedDict(TypedDict): r"""Image generation request input""" model: str r"""The image generation model to use""" prompt: str r"""Text description of the desired image""" aspect_ratio: NotRequired[ImageGenerationRequestAspectRatio] r"""Normalized aspect ratio of the generated image. Providers clamp to their supported subset.""" background: NotRequired[ImageGenerationRequestBackground] r"""Background treatment. `transparent` requires an output_format that supports alpha (png or webp).""" input_references: NotRequired[List[ContentPartImageTypedDict]] r"""Reference images to guide image-to-image generation, as base64 data URLs or HTTP(S) URLs.""" n: NotRequired[int] r"""Number of images to generate (1-10). Providers that only support single-image generation reject n > 1.""" output_compression: NotRequired[int] r"""Compression level (0-100) for webp/jpeg output. Ignored for png and by providers without a compression knob.""" output_format: NotRequired[ImageGenerationRequestOutputFormat] r"""Encoding of the returned image bytes. Most models produce raster formats (png, jpeg, webp). SVG is supported by vectorization models (e.g. Quiver) — the SVG markup is UTF-8 base64-encoded in `b64_json`.""" provider: NotRequired[ImageGenerationRequestProviderTypedDict] r"""Provider-specific passthrough configuration""" quality: NotRequired[ImageGenerationRequestQuality] r"""Rendering quality. Providers without a quality knob ignore this.""" resolution: NotRequired[ImageGenerationRequestResolution] r"""Normalized resolution tier of the generated image. Concrete pixel dimensions are derived per-provider.""" seed: NotRequired[int] r"""If specified, the generation will sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed for all providers.""" size: NotRequired[str] r"""Optional. A convenience shorthand for output dimensions — pass a tier (\"2K\", \"4K\") or explicit pixels (\"2048x2048\") and we normalize it to the right dimensions for the chosen provider. A tier size is equivalent to setting `resolution` and combines with `aspect_ratio`. An explicit pixel size is authoritative: a mismatched `resolution` or `aspect_ratio` alongside it is rejected with a 400.""" stream: NotRequired[bool] r"""If true, partial images are streamed as SSE events as they become available. Only supported by providers with native streaming (currently OpenAI). Non-streaming providers ignore this flag and return a buffered response.""" class ImageGenerationRequest(BaseModel): r"""Image generation request input""" model: str r"""The image generation model to use""" prompt: str r"""Text description of the desired image""" aspect_ratio: Optional[ImageGenerationRequestAspectRatio] = None r"""Normalized aspect ratio of the generated image. Providers clamp to their supported subset.""" background: Optional[ImageGenerationRequestBackground] = None r"""Background treatment. `transparent` requires an output_format that supports alpha (png or webp).""" input_references: Optional[List[ContentPartImage]] = None r"""Reference images to guide image-to-image generation, as base64 data URLs or HTTP(S) URLs.""" n: Optional[int] = None r"""Number of images to generate (1-10). Providers that only support single-image generation reject n > 1.""" output_compression: Optional[int] = None r"""Compression level (0-100) for webp/jpeg output. Ignored for png and by providers without a compression knob.""" output_format: Optional[ImageGenerationRequestOutputFormat] = None r"""Encoding of the returned image bytes. Most models produce raster formats (png, jpeg, webp). SVG is supported by vectorization models (e.g. Quiver) — the SVG markup is UTF-8 base64-encoded in `b64_json`.""" provider: Optional[ImageGenerationRequestProvider] = None r"""Provider-specific passthrough configuration""" quality: Optional[ImageGenerationRequestQuality] = None r"""Rendering quality. Providers without a quality knob ignore this.""" resolution: Optional[ImageGenerationRequestResolution] = None r"""Normalized resolution tier of the generated image. Concrete pixel dimensions are derived per-provider.""" seed: Optional[int] = None r"""If specified, the generation will sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed for all providers.""" size: Optional[str] = None r"""Optional. A convenience shorthand for output dimensions — pass a tier (\"2K\", \"4K\") or explicit pixels (\"2048x2048\") and we normalize it to the right dimensions for the chosen provider. A tier size is equivalent to setting `resolution` and combines with `aspect_ratio`. An explicit pixel size is authoritative: a mismatched `resolution` or `aspect_ratio` alongside it is rejected with a 400.""" stream: Optional[bool] = None r"""If true, partial images are streamed as SSE events as they become available. Only supported by providers with native streaming (currently OpenAI). Non-streaming providers ignore this flag and return a buffered response.""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ "aspect_ratio", "background", "input_references", "n", "output_compression", "output_format", "provider", "quality", "resolution", "seed", "size", "stream", ] ) serialized = handler(self) m = {} for n, f in type(self).model_fields.items(): k = f.alias or n val = serialized.get(k, serialized.get(n)) if val != UNSET_SENTINEL: if val is not None or k not in optional_fields: m[k] = val return m try: ImageGenerationRequestOptions.model_rebuild() except NameError: pass