Picsart API Platform

Guides

Image generation

70 image models cover text-to-image, editing, inpainting, and style transfer. Every one runs through the same generate() call and returns one or more image URLs.

Setup

Create a client once (see Authentication). The snippets below reuse this ai client.

ts
import { createClient } from '@picsart/ai-sdk';

const ai = createClient({
  apiKey: process.env.PICSART_API_KEY,
  apiUrl: 'https://api.picsart.com',
});

Standard parameters

The parameters most image models share. Exact params vary per model — each model page lists its full schema.

ParameterTypeDescription
promptrequiredstringText description of what to generate.
negativePromptstringDescribe what to keep out of the output.
aspectRatiostringOutput aspect ratio, e.g. 16:9, 1:1, 9:16.
resolutionstringOutput resolution, e.g. 720p, 1080p.
countnumberNumber of outputs to return.
imageUrlsstring[]Input / reference image URLs.

Text to image

Give a prompt and, optionally, an aspect ratio. The result URL is on result.url.

ts
const result = await ai.generate('flux-2-pro', {
  prompt: 'A serene mountain lake at golden hour, ultra detailed',
  aspectRatio: '16:9',
});

console.log(result.url);       // primary image URL
console.log(result.results);   // all outputs

Editing & reference images

Models that edit or take reference images accept them via imageUrls — publicly reachable URLs. The CLI uploads a local file for you.

ts
// Pass one or more input images as URLs (see Files & Drive for uploading).
const edited = await ai.generate('seedream-5.0-pro', {
  prompt: 'Replace the background with a snowy forest at dusk',
  imageUrls: ['https://cdn.example.com/photo.jpg'],
});

console.log(edited.url);

Multiple variations

Ask for several outputs at once with count (-n on the CLI). Read them all from result.results.

ts
const { results } = await ai.generate('flux-2-pro', {
  prompt: 'die-cut sticker of a happy robot, white border',
  count: 4,
});

for (const item of results) console.log(item.url);