Multimodal Image Synthesis Tool Dispatcher Script
Generate an automated tool-calling dispatch script that converts raw multimodal user requests into structured diffusion tool payloads.
Use this template when designing an agentic middleware layer that parses multimodal prompts and invokes image generation APIs via structured tool calls. It generates executable routing logic with deterministic schema validation.
Role: Lead Multimodal Agent Architect specializing in function-calling pipelines for generative vision models.
Context
- Target Image Model: {{primary_diffusion_model}}
- Tool Registry Endpoint: {{tool_registry_path}}
- Incoming User Prompt Payload: {{user_intent_payload}}
- Aspect Ratio Constraints: {{aspect_ratio_constraints}}
- Default Negative Prompt Presets: {{negative_prompt_presets}}
- Execution Runtime Environment: {{execution_runtime}}
Task
Write a robust tool-calling orchestration script that ingests multimodal user intent, extracts composition parameters, validates arguments against the tool schema, and dispatches the execution payload to the visual generation backend.
Method
- Ingest {{user_intent_payload}} and parse implicit visual style, subject matter, and color grading cues.
- Cross-reference available visual parameters against {{aspect_ratio_constraints}} to select optimal canvas dimensions.
- Map identified attributes directly into the function call schema defined in {{tool_registry_path}}.
- Merge required system safeguards and styling defaults from {{negative_prompt_presets}} into the tool payload.
- Implement a strict parameter validation step that verifies data types, bounding ranges, and required fields.
- Generate the full runtime invocation script targeted for {{execution_runtime}} using standard tool-calling SDK patterns.
- Include error-handling branches for schema validation failures, token overflow, and unsupported parameter fallbacks.
Constraints
- MUST output valid, fully executable code tailored to {{execution_runtime}} without placeholder functions.
- MUST enforce schema strictness by rejecting unmapped parameters before dispatch.
- MUST NOT hardcode API credentials directly in the script body.
- Use explicit typing and defensive input handling across all generated functions.
Output format
1. Function Calling Schema Definition
JSON Schema describing the tool parameters and constraints.
2. Dispatcher Script
Complete executable script containing initialization, payload transformation, validation, and API invocation.
3. Execution Example
Sample input payload and the resulting parsed function call invocation log.
Self-review
- Confirm every variable from Context is utilized within the script logic.
- Verify the tool schema strictly matches the constraints of {{primary_diffusion_model}}.
- Ensure all exception paths produce actionable error objects.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.