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 — Nano Banana, Imagen, GPT Image, DALL·E, and more. The same endpoint also handles image editing when you pass reference images (aliased as POST /v1/images/edits).
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, imagen-4, gpt-image-1, dall-e-3. |
prompt | string | Yes | Text description of the image to generate. |
n | integer | No | Number of images (1–4). Default: 1 |
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);