Using AI generation and tools through the API
Generate icons, illustrations, 3D and photos, or vectorize and remove backgrounds, with one API key.
The API runs AI generation and AI tools through one endpoint, POST /v3/ai/{operation}. Every request needs your Client ID and Client Secret and uses API credits.
What you can do
|
Operation |
What it does |
What you send |
|---|---|---|
|
|
Generates an icon, illustration, 3D image or photo from a prompt |
Model, prompt, asset type |
|
|
Restyles or edits an image from a prompt |
Model, prompt, reference image |
|
|
Generates a 3D model from a prompt |
Model, prompt, asset type |
|
|
Generates a 3D model from an image |
Model, reference image, asset type |
|
|
Converts a raster image into SVG |
An uploaded file |
|
|
Removes the background from an image |
An uploaded file |
|
|
[Add what Smart Grouping does] |
An uploaded file |
Which operations your plan includes
- The Free plan includes Vectorizer, Background Remover and Smart Grouping.
- Generation, Reimagine and the 3D Generator need a paid plan.
- AI must also be turned on for your app. Choose AI Generation & Tools under API Products when you create the app.
To check, call GET /v3/ai/operations. It lists every operation with available_on_your_plan, its credit cost and its upload size limit. GET /v3/ai/models lists the models for each operation and what each costs. Read costs from these instead of hard-coding them, since prices can change.
How to generate
- Pick a model for the operation from
GET /v3/ai/models. - Send
POST /v3/ai/{operation}with your fields (below). - You get a 202 response with one task ID per output, plus a
Retry-Aftervalue telling you how often to check. - Poll
GET /v3/ai/tasks/{task_id}everyRetry-Afterseconds until the status is COMPLETED or FAILED. Generation usually takes tens of seconds. - Download your files from
generatedin the completed task. The links expire, so save the files straight away.
curl -X POST "https://api.iconscout.com/v3/ai/text-to-image" \ -H "Client-ID: $ICONSCOUT_CLIENT_ID" \ -H "Client-Secret: $ICONSCOUT_CLIENT_SECRET" \ -H "Content-Type: application/json" \ -d '{"model":"recraft-vector","asset":"icon","prompt":"Rocket launching, outline style"}'
Request fields for generation
|
Field |
Required? |
Details |
|---|---|---|
|
|
Yes |
A model listed for the operation |
|
|
Yes, except for |
Prompts that break the content policy are refused |
|
|
For |
|
|
|
Depends on the operation |
A public image URL: JPEG, PNG, WebP or AVIF, 256–4096 px, under 5 MB. Not allowed for |
|
|
No |
How many outputs. Each one uses credits. |
|
|
No |
1:1 (default), 16:9, 3:2, 2:3, 4:5, 5:4, 9:16, 3:4 or 4:3 |
For vectorize, remove-background and smart-group, send just a file as multipart form data. Images must be between 256×256 and 4096×4096 px. Accepted types and the size limit are listed in GET /v3/ai/operations.
Task statuses
|
Status |
Meaning |
|---|---|
|
CREATED |
The task is queued |
|
IN_PROGRESS |
The output is being generated |
|
COMPLETED |
Your files are ready in |
|
FAILED |
Generation didn't work. You aren't charged. |
Getting an SVG
- The vector models,
recraft-vectorandrecraft-vector-pro, return an SVG as soon as the task completes. - Other models return a raster image. For icons and illustrations, a traced SVG is added shortly after COMPLETED, so poll once more to get it.
Credits
- Credits are held when you send the request and returned if the work fails, so you're never charged for failed work.
- Every response shows
credits_chargedand your remaining balance. - Cost depends on the operation and, for generation, the model.
Optional headers
Idempotency-Key: stops the same request running twice if you retry it.X-Project-Reference: your own label for the project or customer, so you can see spend per project in reporting.
Common errors
|
Error |
Reason |
What to do |
|---|---|---|
|
403 |
|
Your plan doesn't include this operation, or AI is off for your app |
|
409 |
Idempotency key already used |
Use a new key, or poll the task from the first request |
|
413 |
File too large |
Check |
|
422 |
|
A field is missing or wrong, for example an unsupported model |
|
422 |
|
The prompt breaks the acceptable use policy |
|
422 |
|
Check the image's type, size and dimensions |
|
429 |
|
Too many requests. Wait for |
|
429 |
|
Your credits for this period are used up. Waiting won't help. Upgrade or wait for your reset (Article 8). |
|
503 |
|
The AI provider is busy. You aren't charged. Try again later. |
Tips
- Call
GET /v3/ai/operationsfirst. Otherwise a request your plan doesn't cover may return a validation error before it returns the 403. - Poll at the
Retry-Afterinterval. Polling faster won't speed things up and can hit your rate limit. - Prompts work best as subject, then style, then constraints. For more details, visit IconScout API docs.