Guides
Text & analysis
5 text models (Claude, GPT, Gemini) handle text generation and image understanding. They use generateText() and return a string rather than an asset URL.
The gen-ai CLI focuses on image, video, and audio generation. Call text models through the SDK (below) or the REST API.
Generate text
ts
import { createClient } from '@picsart/ai-sdk';
const ai = createClient({
apiKey: process.env.PICSART_API_KEY,
apiUrl: 'https://api.picsart.com',
});
// Text/LLM models use generateText() — they return a string, not a URL.
const { text } = await ai.generateText('claude-opus-4-8', {
prompt: 'Summarize the theory of relativity in two sentences.',
});
console.log(text);Image understanding (vision)
Multimodal models accept images as URLs via imageUrls — pass one or more alongside the prompt to describe, extract, or reason over them.
ts
// Analyze an image by passing it as a URL alongside the prompt.
const { text } = await ai.generateText('claude-opus-4-8', {
prompt: 'Describe what is happening in this photo, then suggest a caption.',
imageUrls: ['https://cdn.example.com/photo.jpg'],
});
console.log(text);Reading the raw response
generateText() returns the text plus a raw field with provider metadata (usage, finish reason, etc.).
ts
// The raw response carries usage, finish reason, and (where supported)
// the model's thinking trace.
const res = await ai.generateText('gpt-5.5', {
prompt: 'List three name ideas for a coffee brand.',
});
console.log(res.text);
console.log(res.raw); // provider-specific metadata