SDK
sdk.edit() + generate()
Edit images with natural language prompts and generate new images from text
sdk.edit() + generate()
Transform existing images with natural language instructions, or generate entirely new images from text descriptions.
Interactive Demo
Try it out ↓
sdk.edit()
Edit an image using a natural language prompt.
Signature
sdk.edit(image: string, options: EditOptions): Promise<string>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
image | string | Yes | Image URL or base64 data URI |
options.prompt | string | Yes | Edit instruction (e.g. "make it look vintage") |
options.aspectRatio | string | No | Output aspect ratio: "match_input_image", "1:1", "16:9", "9:16", "4:3", "3:4" |
options.outputFormat | string | No | "jpg" or "png" |
options.model | string | No | Model to use (default: "flux-kontext-max") |
Returns
Promise<string> — URL or base64 of the edited image.
Examples
import { CoreViz } from '@coreviz/sdk';
const sdk = new CoreViz({ apiKey: process.env.COREVIZ_API_KEY });
// Style transfer
const edited = await sdk.edit('https://example.com/photo.jpg', {
prompt: 'Make it look like a vintage film photograph',
aspectRatio: '1:1',
outputFormat: 'jpg',
});
// Object replacement
const result = await sdk.edit('https://example.com/product.jpg', {
prompt: 'Change the background to a clean white studio backdrop',
});
// Color adjustment
const colorFixed = await sdk.edit('https://example.com/raw.jpg', {
prompt: 'Enhance the colors and increase contrast',
});sdk.generate()
Generate a new image from a text description, optionally using reference images for style guidance.
Signature
sdk.generate(prompt: string, options?: GenerateOptions): Promise<string>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text description of the image to generate |
options.referenceImages | string[] | No | Reference image URLs or base64 strings for style/structure guidance |
options.aspectRatio | string | No | Target aspect ratio (e.g. "1:1", "16:9", "4:3") |
options.model | string | No | Model to use |
Returns
Promise<string> — URL of the generated image.
Examples
// Text-to-image
const url = await sdk.generate('A product photo of running shoes on a white background', {
aspectRatio: '1:1',
});
// With style reference
const styled = await sdk.generate('A hero banner for a summer fashion campaign', {
referenceImages: ['https://example.com/brand-style.jpg'],
aspectRatio: '16:9',
});Use Cases
- Creative editing — apply styles, change backgrounds, retouch
- Batch processing — script image edits at scale
- Prototyping — generate placeholder visuals from descriptions
- Brand consistency — generate on-brand variations from a style reference
Raw API Endpoint
These methods call POST /api/ai/edit and POST /api/ai/generate. See the Vision API Reference for raw HTTP details.