Image Generation

Generate and edit images from text prompts across all supported image models.

POST/v1/images/generations

Generate 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

FamilyModel IDsPricing knob
GPT Imagegpt-image-1-mini, gpt-image-1, gpt-image-1.5, gpt-image-2quality: low, medium or high — omitted bills high
Nano Banananano-banana-flash-lite, nano-banana, nano-banana-2, nano-banana-proresolution: 0.5K, 1K, 2K or 4K (availability per model)
FLUX.2flux-2-pro, flux-2-flexFlat rate per image; aspect_ratio and resolution pass through
Seedreamseedream-4.5, seedream-5-lite, seedream-5-proFlat 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.

ParameterTypeRequiredDescription
modelstringYesAny image model ID — e.g. nano-banana-pro, gpt-image-1, flux-2-pro, seedream-4.5.
promptstringYesText description of the image to generate.
nintegerNoNumber of images (1–4). Default: 1. Nano Banana models return one image per call, so n is clamped to 1 there.
response_formatstringNob64_json (default — base64 in response) or url (hosted URL). Model support varies.
imagesstring[]NoBase64-encoded reference images for editing. The max number accepted depends on the model (e.g. 14 for Nano Banana, 16 for GPT Image).
userstringNoOptional 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);

On this page