ai_generate_image
Need a hero, product image, social card, thumbnail, or draft visual? ai_generate_image creates it from a text prompt without wiring a separate image provider. Returns image bytes (base64) or a stored path plus cost.
Two managed models, priced in ai_catalog. Which model: omit model for fast, low-cost drafts (@cf/black-forest-labs/flux-1-schnell, fixed 1024×1024, billed per tile and step); gpt-image-2.5-flare suits final assets, legible text, UI mockups or a transparent background (reserves balance up front; a successful call uses reported token usage capped at that reservation, or the calculator estimate when usage is missing). Failed GPT Image calls return the reservation; an unconfirmed return is reported as settlement: 'unconfirmed'. Earlier retired managed models are refused with a message naming the default. For any other model, bring your own provider: store the vendor's key as a project secret and call the vendor from your own function; there is no managed AI charge on that path (the vendor bills you directly; your function's ordinary platform usage still applies).
Inline rendering: Pass inline: true to get the image as an MCP image content block alongside the JSON result. An MCP client that supports image content blocks can render it directly. Default inline: false keeps the response lightweight (base64 only when not stored).
Example:
{
"project_id": "my-saas",
"prompt": "A minimalist logo for a fitness app, clean lines, blue and white",
"inline": true
}Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_id": "<project_id>",
"prompt": "<prompt>"
},
"name": "ai_generate_image"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Optional. @cf/black-forest-labs/flux-1-schnell (default) or gpt-image-2.5-flare; other ids are refused with a typed error. | |
| steps | No | Default model only: inference steps, 1-8 (default 4). | |
| width | No | gpt-image-2.5-flare: with height, picks the shape (wider 1536×1024, taller 1024×1536, else 1024×1024). Ignored by the default model, which renders 1024×1024. | |
| height | No | gpt-image-2.5-flare: with width, picks the shape. Ignored by the default model. | |
| inline | No | When true, the image comes back as an MCP image content block that supporting clients render inline. Default false. | |
| prompt | Yes | Image description (max 2000 chars). | |
| quality | No | gpt-image-2.5-flare only (default medium). Refused on the default model. | |
| storage | No | Optional storage path like /images/hero.png. When set, saves to the project filesystem. | |
| background | No | gpt-image-2.5-flare only (default auto); transparent returns a PNG with alpha. Refused on the default model. | |
| project_id | Yes | Project ID (UUID), subdomain, or slug — resolved server-side, no UUID lookup needed. 'default' also works when the account has exactly one project; multi-project accounts must name one (the error lists them). |