ImageGenerationTool(*, quality=None, size=None, background=None, output_format=None, output_compression=None, partial_images=None)
Bases: Tool
Builtin image generation tool for the OpenAI Responses API.
Instructs the model to generate images inline during the conversation. Only supported with OpenAIResponsesConfig — raises UnsupportedToolError when used with OpenAIConfig (Chat Completions API).
Generated images are returned as list[bytes] via reply.images.
| PARAMETER | DESCRIPTION |
quality | Image quality — "low", "medium", "high", or "auto". TYPE: Literal['low', 'medium', 'high', 'auto'] | None DEFAULT: None |
size | Image dimensions, e.g. "1024x1024", "1536x1024", "auto". TYPE: str | None DEFAULT: None |
background | Background type — "transparent", "opaque", or "auto". TYPE: Literal['transparent', 'opaque', 'auto'] | None DEFAULT: None |
output_format | Output format — "png", "jpeg", or "webp". TYPE: Literal['png', 'jpeg', 'webp'] | None DEFAULT: None |
output_compression | Compression level 0–100 (webp/jpeg only). TYPE: int | None DEFAULT: None |
partial_images | Number of partial images to stream (1–3). TYPE: int | None DEFAULT: None |
Source code in autogen/beta/tools/builtin/image_generation.py
| def __init__(
self,
*,
quality: Literal["low", "medium", "high", "auto"] | None = None,
size: str | None = None,
background: Literal["transparent", "opaque", "auto"] | None = None,
output_format: Literal["png", "jpeg", "webp"] | None = None,
output_compression: int | None = None,
partial_images: int | None = None,
) -> None:
self._params: dict[str, object] = {}
if quality is not None:
self._params["quality"] = quality
if size is not None:
self._params["size"] = size
if background is not None:
self._params["background"] = background
if output_format is not None:
self._params["output_format"] = output_format
if output_compression is not None:
self._params["output_compression"] = output_compression
if partial_images is not None:
self._params["partial_images"] = partial_images
|
Source code in autogen/beta/tools/builtin/image_generation.py
| async def schemas(self, context: "Context") -> list[ImageGenerationToolSchema]:
return [ImageGenerationToolSchema(**self._params)]
|
register(stack, context, *, middleware=())
Source code in autogen/beta/tools/builtin/image_generation.py
| def register(
self,
stack: "ExitStack",
context: "Context",
*,
middleware: Iterable["BaseMiddleware"] = (),
) -> None:
pass
|