Get started
Quickstart
Create a client once, then call any model. Media models return URLs; text models return strings.
1. Generate an image
TypeScript
import { createClient } from '@picsart/ai-sdk';
const ai = createClient({
apiKey: process.env.PICSART_API_KEY,
apiUrl: 'https://api.picsart.com',
});
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 result items2. Generate text
LLM/text models use generateText(), which returns the generated text plus the raw response.
TypeScript
const { text } = await ai.generateText('claude-opus-4-8', {
prompt: 'Summarize the theory of relativity in two sentences.',
});
console.log(text);3. Handle long-running jobs
generate() waits for the result. For slower media (video), use submit() + result() so you control polling.
TypeScript
// For long-running jobs (video), submit and poll instead of blocking:
const handle = await ai.submit('kling-v3', {
prompt: 'A drone shot flying over a canyon at sunrise',
duration: 5,
});
const result = await ai.result(handle, 'kling-v3');
console.log(result.url); // video URLEvery model page shows copy-pasteable SDK and API examples using that model's exact parameters. Explore models →