Controlling hosted image_generation tool parameters at runtime
#6904
Replies: 2 comments 1 reply
-
|
Additionally, I would also require a support for editing a specific previously-generated image with the hosted Concrete scenario
Expected: image A, edited (dinosaur recolored red), preserving the original composition. Question: is there any recommended pattern for such flow? |
Beta Was this translation helpful? Give feedback.
-
|
Hi @CristinaStn, Today the hosted In the Python path, So if you need deterministic runtime control, the recommended patterns are:
image_tool = FoundryChatClient.get_image_generation_tool(
model="gpt-image-2",
size="1024x1024",
quality="high",
output_format="jpeg",
)
result = await agent.run(
user_message,
stream=True,
tools=[image_tool],
)I would avoid also registering a static default image-generation tool on the agent if you want to vary it per request; create/pass the configured hosted tool for the specific run.
For editing a previously generated image, the current practical pattern is similar: persist the generated image artifact in your application and include the specific image again as input when asking for an edit. Agent Framework parses image-generation results as image content, and image The TL;DR; is: use hosted |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
We have a gpt-5 agent that has access to the hosted
image_generationtool, which is backed by a gpt-image-2 deployment (routed via thex-ms-oai-image-generation-deploymentheader). We use it throughFoundryChatClient.get_image_generation_tool(...). Its parameters (size,quality,output_format,background, ...) are set once, in the tool definition when the agent is built.We'd like the agent to choose these per request at runtime (e.g. the user asks for a JPEG, or a 1024x1024 high quality image),
but we can't find a supported way to do that with the hosted tool, and would appreciate the recommended pattern.
Concrete example (the core problem)
User query:
The image generates, but the effective config gpt-image-2 used (read from the
image_generation_tool_callcontent'sraw_representation.model_extra) are:So of four explicit user requests:
output_format: jpeg→ gotpng(ignored)size: 1024x1024→ got1254x1254(ignored — and not even one of the documented sizes)quality: high→ gotlow(ignored)backgroundnot requested) →opaqueGpt-5 clearly parsed the intent (it's in the user text), but with the hosted tool it has no way to pass
output_format/sizeinto the call, and the server-sideautoresolution does not honor them. This is our exact pain point.Question: What is the best practice to use native image generation tool with runtime configurable parameters?
Environment
agent-framework-core/agent-framework-foundry/agent-framework-openai==1.10.0openai==2.8.1,azure-ai-projects==2.2.0FoundryChatClient(Azure AI Foundry project endpoint), streaming runsgpt-image-2deployment, routed via thex-ms-oai-image-generation-deploymentheader on the OpenAI clientBeta Was this translation helpful? Give feedback.
All reactions