Image Generation
Generate and edit images from text prompts across all supported image models.
/v1/images/generationsGenerate images from text prompts across all supported image models — GPT Image, Nano Banana, FLUX.2, Seedream, and more. The same endpoint also handles image editing when you pass reference images (aliased as POST /v1/images/edits).
Image families
| Family | Model IDs | Pricing knob |
|---|---|---|
| GPT Image | gpt-image-1-mini, gpt-image-1, gpt-image-1.5, gpt-image-2 | quality: low, medium or high — omitted bills high |
| Nano Banana | nano-banana-flash-lite, nano-banana, nano-banana-2, nano-banana-pro | resolution: 0.5K, 1K, 2K or 4K (availability per model) |
| FLUX.2 | flux-2-pro, flux-2-flex | Flat rate per image; aspect_ratio and resolution pass through |
| Seedream | seedream-4.5, seedream-5-lite, seedream-5-pro | Flat rate per image; aspect_ratio and resolution pass through |
Each model's page shows its current credit price per image, and X-Credits-Used on the response tells you what a call actually cost. A non-square size (e.g. 1536x1024) is billed at 1.5× the square price on every model except gpt-image-2 and the Nano Banana family, which price by resolution instead. Passing aspect_ratio rather than size carries no surcharge.
Common request body
The fields below are shared by every image model. Model-specific options — size, aspect_ratio, resolution, quality, output_format, negative_prompt, seed, background, etc. — depend on the family. Open the model on Models and switch to the API tab for the full parameter reference.
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Any image model ID — e.g. nano-banana-pro, gpt-image-1, flux-2-pro, seedream-4.5. |
prompt | string | Yes | Text description of the image to generate. |
n | integer | No | Number of images (1–4). Default: 1. Nano Banana models return one image per call, so n is clamped to 1 there. |
response_format | string | No | b64_json (default — base64 in response) or url (hosted URL). Model support varies. |
images | string[] | No | Base64-encoded reference images for editing. The max number accepted depends on the model (e.g. 14 for Nano Banana, 16 for GPT Image). |
user | string | No | Optional end-user identifier for abuse monitoring. |
Example
Swap model for any image model ID — parameters beyond those shown below must match that model's API tab.
import Tchavi from '@tchavi/sdk';
const client = new Tchavi({ apiKey: 'YOUR_API_KEY' });
const result = await client.images.generations.create({
model: 'YOUR_MODEL_ID',
prompt: 'A colorful parrot on a branch, digital art',
});
console.log(result.data[0].b64_json);
console.log('Credits used:', result.tchavi.credits_used);The response contains base64-encoded image data in data[0].b64_json. Here's how to use it:
// Display the image in a browser
const img = document.createElement('img');
img.src = `data:image/png;base64,${data.data[0].b64_json}`;
document.body.appendChild(img);