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[BinaryResult] via reply.files.
| PARAMETER | DESCRIPTION |
quality | Image quality — "low", "medium", "high", or "auto". TYPE: Literal['low', 'medium', 'high', 'auto'] | Variable | None DEFAULT: None |
size | Image dimensions, e.g. "1024x1024", "1536x1024", "auto". TYPE: str | Variable | None DEFAULT: None |
background | Background type — "transparent", "opaque", or "auto". TYPE: Literal['transparent', 'opaque', 'auto'] | Variable | None DEFAULT: None |
output_format | Output format — "png", "jpeg", or "webp". TYPE: Literal['png', 'jpeg', 'webp'] | Variable | None DEFAULT: None |
output_compression | Compression level 0–100 (webp/jpeg only). TYPE: int | Variable | None DEFAULT: None |
partial_images | Number of partial images to stream (1–3). TYPE: int | Variable | None DEFAULT: None |
Source code in autogen/beta/tools/builtin/image_generation.py
| def __init__(
self,
*,
quality: Literal["low", "medium", "high", "auto"] | Variable | None = None,
size: str | Variable | None = None,
background: Literal["transparent", "opaque", "auto"] | Variable | None = None,
output_format: Literal["png", "jpeg", "webp"] | Variable | None = None,
output_compression: int | Variable | None = None,
partial_images: int | Variable | 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
self.name = IMAGE_GENERATION_TOOL_NAME
|
name = IMAGE_GENERATION_TOOL_NAME
Source code in autogen/beta/tools/builtin/image_generation.py
| async def schemas(self, context: "Context") -> list[ImageGenerationToolSchema]:
resolved = {k: resolve_variable(v, context, param_name=k) for k, v in self._params.items()}
return [ImageGenerationToolSchema(**resolved)]
|
register(stack, context, *, middleware=())
Source code in autogen/beta/tools/builtin/image_generation.py
| def register(
self,
stack: "ExitStack | AsyncExitStack",
context: "Context",
*,
middleware: Iterable["BaseMiddleware"] = (),
) -> None:
async def execute(event: "ToolCallEvent", context: "Context") -> None:
pass
stack.enter_context(
context.stream.where(BuiltinToolCallEvent.name == IMAGE_GENERATION_TOOL_NAME).sub_scope(execute),
)
|
Source code in autogen/beta/tools/tool.py
| def set_provider(self, provider: Provider) -> None:
pass
|