Skip to main content
Glama

Generate Image (OpenRouter)

pixara_generate_image

Generate images from text prompts using any OpenRouter image model. Saves files and returns paths, model, and cost.

Instructions

Generate an image from a text prompt using any image model available on OpenRouter.

This calls OpenRouter's dedicated Image API (not chat completions) and saves the resulting image(s) to disk, returning the file path(s), model used, and cost. It does NOT edit or use reference images — for image-to-image/editing, use pixara_edit_image instead.

Args:

  • model (string): OpenRouter model slug, e.g. 'black-forest-labs/flux-1.1-pro' or 'openai/gpt-image-1'. Use pixara_list_image_models to discover options.

  • prompt (string): Text description of the desired image.

  • n (number, 1-10, default 1): Number of images to generate. Not all models support n > 1.

  • resolution ('512'|'1K'|'2K'|'4K', optional): Resolution tier.

  • aspect_ratio (string, optional): e.g. '16:9', '1:1'. Don't combine with 'size'.

  • size (string, optional): Convenience tier or explicit dimensions. Don't combine with resolution/aspect_ratio.

  • quality ('auto'|'low'|'medium'|'high', optional)

  • output_format ('png'|'jpeg'|'webp', default 'png')

  • background ('auto'|'transparent'|'opaque', optional): 'transparent' requires png/webp.

  • output_compression (0-100, optional): webp/jpeg only.

  • seed (number, optional): For deterministic generation where supported.

  • provider_options (object, optional): Provider-specific passthrough params. Check pixara_get_model_details first for allowed keys.

  • output_dir (string, optional): Where to save images (default: OPENROUTER_IMAGE_OUTPUT_DIR).

  • filename_prefix (string, optional): Prefix for saved filenames.

Returns: Markdown summary listing each saved file's path, media type, size in bytes, and the total cost charged by OpenRouter for the request.

Examples:

  • Use when: "Generate a picture of a red panda astronaut" -> model + prompt only

  • Use when: "Make a transparent-background product shot" -> background='transparent', output_format='png'

  • Don't use when: you have a reference image to transform (use pixara_edit_image)

Error Handling:

  • "Insufficient OpenRouter credits" -> add credits at https://openrouter.ai/credits

  • "Bad request" / conflicting params -> re-check with pixara_get_model_details

  • "Rate limited" -> wait and retry

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nNoNumber of images to generate (1-10). Not all models support n > 1.
seedNoSeed for deterministic generation, where supported.
sizeNoConvenience shorthand for either a tier ('2K') or explicit dimensions ('2048x2048'). Don't combine with 'resolution' or 'aspect_ratio'.
modelYesOpenRouter model slug, e.g. 'black-forest-labs/flux-1.1-pro' or 'openai/gpt-image-1'. Use pixara_list_image_models to discover available models.
promptYesText description of the desired image.
qualityNoQuality tier: 'auto', 'low', 'medium', or 'high'.
backgroundNoBackground handling: 'auto', 'transparent', or 'opaque'. 'transparent' requires output_format 'png' or 'webp'.
output_dirNoDirectory to save generated images into. Defaults to OPENROUTER_IMAGE_OUTPUT_DIR.
resolutionNoResolution tier: '512', '1K', '2K', or '4K'. Don't combine with 'size'.
aspect_ratioNoAspect ratio, e.g. '16:9' or '1:1'. Don't combine with 'size'.
output_formatNoOutput image format: 'png', 'jpeg', or 'webp'.png
filename_prefixNoPrefix for saved image filenames (default: 'openrouter-image').
provider_optionsNoProvider-specific passthrough params, keyed by provider slug, e.g. { 'black-forest-labs': { steps: 40, guidance: 3 } }. Check pixara_get_model_details for each provider's allowed_passthrough_parameters before using this.
output_compressionNoCompression level 0-100, only applies to 'webp'/'jpeg' output_format.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses that the tool saves images to disk, calls OpenRouter's Image API (not chat), and returns file paths and cost. No annotation contradictions; adds context beyond annotations such as error handling and environment variable usage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with sections: summary, args, returns, examples, error handling. Slightly lengthy but justified by the tool's complexity (14 params); no unnecessary sentences.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema but describes return format adequately. Covers error scenarios, environment variable defaults, and sibling tool references. Thorough for a complex tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, baseline 3. Description adds significant value by explaining parameter constraints (e.g., n>1 not universal), mutual exclusivity rules, and defaults, surpassing basic schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the tool generates images from text prompts using OpenRouter models. Distinguishes itself from sibling pixara_edit_image by explicitly noting it does not edit or use reference images.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use and when-not-to-use examples, plus alternatives like pixara_edit_image for editing. Also references pixara_list_image_models for model discovery and error handling guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pinkpixel-dev/pixara-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server