Skip to content
  • There are no suggestions because the search field is empty.

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

text-to-image

Generates an icon, illustration, 3D image or photo from a prompt

Model, prompt, asset type

image-to-image

Restyles or edits an image from a prompt

Model, prompt, reference image

text-to-3d

Generates a 3D model from a prompt

Model, prompt, asset type

image-to-3d

Generates a 3D model from an image

Model, reference image, asset type

vectorize

Converts a raster image into SVG

An uploaded file

remove-background

Removes the background from an image

An uploaded file

smart-group

[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

  1. Pick a model for the operation from GET /v3/ai/models.
  2. Send POST /v3/ai/{operation} with your fields (below).
  3. You get a 202 response with one task ID per output, plus a Retry-After value telling you how often to check.
  4. Poll GET /v3/ai/tasks/{task_id} every Retry-After seconds until the status is COMPLETED or FAILED. Generation usually takes tens of seconds.
  5. Download your files from generated in 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

model

Yes

A model listed for the operation

prompt

Yes, except for image-to-3d

Prompts that break the content policy are refused

asset

For text-to-image, text-to-3d, image-to-3d

icon, illustration, 3d or photo. The model must support it.

image_url

Depends on the operation

A public image URL: JPEG, PNG, WebP or AVIF, 256–4096 px, under 5 MB. Not allowed for text-to-3d.

num_images

No

How many outputs. Each one uses credits.

aspect_ratio

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 generated

FAILED

Generation didn't work. You aren't charged.

Getting an SVG

  • The vector models, recraft-vector and recraft-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_charged and 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

entitlement_required

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 max_upload_kb in GET /v3/ai/operations

422

invalid_request

A field is missing or wrong, for example an unsupported model

422

prompt_rejected

The prompt breaks the acceptable use policy

422

invalid_reference_image

Check the image's type, size and dimensions

429

rate_limit_exceeded

Too many requests. Wait for Retry-After.

429

quota_exhausted

Your credits for this period are used up. Waiting won't help. Upgrade or wait for your reset (Article 8).

503

provider_unavailable

The AI provider is busy. You aren't charged. Try again later.

Tips

  • Call GET /v3/ai/operations first. Otherwise a request your plan doesn't cover may return a validation error before it returns the 403.
  • Poll at the Retry-After interval. 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.