Generate or edit an image
generate_imageGenerate one or more images from a prompt with topx-image, or with topx-image-fast when the call names it for a faster image, optionally following reference images or editing an image (pass images, and mask to change only part of the first image). Billed at the model's per-image price plus a $0.01 call fee; input images are billed as image input tokens. Returns the images inline and as temporary signed links valid for up to one hour; cache capacity may expire them earlier.
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": {
"prompt": "<prompt>"
},
"name": "generate_image"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images. | |
| mask | No | Optional mask for the first image, as a data URL or https link: a PNG of the same width and height whose fully transparent pixels mark the area to change. The model treats it as a guide, so the edit may reach slightly past it. | |
| size | No | WIDTHxHEIGHT, for example 1024x1024, 1536x1024, 1024x1536 or 2048x2048. | 1024x1024 |
| model | No | The topx- ID of the image model: topx-image, or topx-image-fast for a faster image. | |
| images | No | Optional reference images, or the image to edit: up to 16 PNG, JPEG or WebP images as data URLs (data:image/png;base64,...) or https links, including the links an earlier generate_image call returned. Say in the prompt how to use each, by its position: for example "Put the chair from image 2 into the room in image 1, keep the lighting of image 1". The first image is the one an edit changes and the one mask applies to. Billed as input image tokens on top of the output images. | |
| prompt | Yes | What to draw, or what to change in the images. Name a style by its movement and what it looks like (Post-Impressionist, swirling impasto, bold outlines) rather than by an artist or named artworks, and write it in one language: the image model's safety filter refuses some prompts that combine those, and refuses them again unchanged. | |
| quality | No | Optional rendering quality. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | ||
| size | No | ||
| urls | No | Temporary signed links, valid for up to one hour; capacity eviction may expire them earlier. | |
| error | No | Present on a failed call: category (client, wallet, topxai, upstream, budget), message, charged, charged_usd. | |
| model | No | ||
| images | No | Images returned inline as image content blocks. | |
| masked | No | Whether a mask limited the edit to part of the first image. | |
| charged | No | Whether the wallet was debited for this call. | |
| request_id | No | The relay request id; the same id appears in the usage log. | |
| charged_usd | No | The recorded wallet debit in USD, model price and call fee included. | |
| inline_urls | No | Links already represented by inline image content; avoid duplicate previews. | |
| call_fee_usd | No | ||
| input_images | No | Images the call sent as references or to edit. | |
| generated_images | No | Images returned by the generation, including files linked instead of embedded. |