Get started
Quickstart
Create a client once, then call any model. Media models return URLs; text models return strings.
Generate an image
TypeScriptimport { 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.items); // all result itemsGenerate text
LLM/text models use
generateText(), which returns the generated text plus the raw response.TypeScriptconst { text } = await ai.generateText('claude-opus-4-8', { prompt: 'Summarize the theory of relativity in two sentences.', }); console.log(text);Handle long-running jobs
generate()waits for the result. For slower media (video), usesubmit()+result()so you control polling.TypeScript// For long-running jobs (video), submit and poll instead of blocking: const generationId = await ai.submit('kling-v3', { prompt: 'A drone shot flying over a canyon at sunrise', duration: 5, }); const result = await ai.result('kling-v3', generationId); console.log(result.url); // video URL
Tip
Every model page shows copy-pasteable SDK and API examples using that model's exact parameters.