Skip to content

Generation API

An SVG generation API. A prompt goes in, optimised markup comes back.

Updated

Put vector generation behind your own product: a design tool, a template engine, a content pipeline, a bulk asset job. JSON in, cleaned SVG out, with the result stored so you can fetch it again. This is a REST service you call from a server — not the browser SVG DOM that MDN documents under the same name.

request
curl -X POST \
  https://api.svgmakerai.com/svg/create-svg-from-text \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "faceted fox head, flat vector",
    "modelType": "normal",
    "width": 1024,
    "height": 1024
  }'
200 OK
{
  "success": true,
  "message": "AI SVG generated successfully
              and 1 credits deducted",
  "data": {
    "_id": "…",
    "title": "faceted fox head, fla…",
    "prompt": "faceted fox head, flat vector",
    "svgContent": "<svg viewBox=…>…</svg>",
    "generationMethod": "ai-text",
    "isPublic": false
  }
}

Three things called an SVG API

Which one you are looking for.

The phrase covers three unrelated things and only one of them is a service you call over the network. Two minutes here saves reading the wrong documentation.

The browser SVG DOM API

MDN, the SVG specification, Apache Batik

The JavaScript interfaces — SVGElement, SVGPathElement, SVGSVGElement — for reading and changing vector nodes already on a page. It ships with every browser, costs nothing and needs no account. If you are scripting shapes in a document, that is what you want and this page is not it.

An icon or logo REST API

Iconify, SVGL, svgapi.com

Services that return an existing icon from a catalogue by name or search. Enormous libraries, usually free, and the right answer whenever the artwork you need already exists and somebody has drawn it.

A generation API

This page

A service that creates artwork that did not exist before, from a description or an uploaded image, and hands back vector markup. Useful precisely when the asset is not in anybody's catalogue — per-user, per-listing, per-tenant artwork.

Endpoints

Two that generate. Ten that read or manage.

Only the first two consume credits. Everything else is workspace, gallery and account reads and costs nothing. Paths are relative to https://api.svgmakerai.com.

API endpoints with method, auth and credit cost
MethodPathAuthCostBodyWhat it does
POST/svg/create-svg-from-textbearer1 – 2 creditsJSON: prompt (required), modelType, width, heightExpands the prompt, generates vector geometry, optimises the markup and stores the result in your workspace. width and height are the size asked of the model and the fallback viewBox.
POST/svg/convert-image-to-svgbearer1 – 2 creditsmultipart: image (required), modelType, width, height; prompt is stored as the title onlyDescribes the uploaded image, then generates a new SVG from that description — a redraw, not a trace. Images only, up to 10 MB.
POST/svg/save-svgbearerFreeJSON: svgContent (required), title, category, isPublicStores markup you produced or edited yourself, so hand-authored files live alongside generated ones.
GET/svg/get-all-svgsbearerFreequery: page, limit, search, categoryLists the calling account's own files, newest first. Omit page and limit to get everything.
GET/svg/get-svg/:idbearer, optionalFree—Fetches one file. A private file is returned to its owner only; anyone else gets 404.
GET/svg/public-gallerypublicFreequery: page, limit (max 60), search, category, sort=popularReads the public gallery. No session needed.
PATCH/svg/toggle-public/:idbearerFreeJSON: isPublic, categoryPublishes or unpublishes one of your own files. Omit isPublic to flip the current state. Owner-only.
DELETE/svg/delete-svg/:idbearerFree—Deletes one of your own files. Owner-only.
GET/svg/get-public-svg/:idpublicFree—Fetches a published file without a session. Returns nothing for anything still private.
POST/svg/public-gallery/:id/downloadpublicFree—Registers a download against a gallery item. Use it if you are surfacing the gallery in your own interface and want the counts to stay honest.
DELETE/svg/clear-all-svgbearerFree—Empties the calling account's workspace. There is no undo, so gate it behind a confirmation of your own.
GET/auth/user-databearerFree—Returns the calling account, including its credit balance. Check it before a long run.

Behaviour

Six things worth knowing before you integrate.

Your account's bearer token

Send Authorization: Bearer <token> — the account token the dashboard itself sends. There are no separate API keys. No token gets 401; a token that does not verify, or has expired, gets 403. Tokens last 30 days — sign in again for a new one.

Credits are checked first

If the balance is below the cost of the run, the request returns 400 naming the credits the tier needs, and nothing is charged.

Optimisation is not optional

Generated markup goes through SVGO before it is returned: editor metadata stripped, width and height removed (the viewBox stays), class and data-name removed, numbers trimmed to two decimals.

Everything is stored

Each generation creates a record you can list, fetch, publish or delete. A failed copy to file storage does not fail the generation — the markup is in the record either way.

Two fidelity tiers

modelType defaults to normal at one credit. Setting it to premium uses the higher-fidelity vector model at two.

Mostly one response shape

The /svg handlers answer with JSON carrying success and message, and failures add an error field. Token rejections and /auth/user-data carry no success field, so branch on the status code.

Failure modes

The five responses you will actually handle.

Every failure carries a human-readable message, and those from the /svg handlers add success: false, so branch on the status code and show the message.

  • 400Missing prompt, image or svgContent — or not enough credits for the tier you asked for.
  • 401No bearer token on a route that requires one.
  • 403The token does not verify or has expired — or you tried to publish another account's file.
  • 404No such file, a private file that is not yours, or — on the public routes — a file that has not been published.
  • 500Generation failed upstream. Nothing is charged; retry the call.

Questions

Integrating the API.

Is this the same as the SVG API on MDN?
No, and the collision is worth clearing up. MDN documents the browser's SVG DOM — the JavaScript interfaces for manipulating vector elements already in a page. That is part of the platform, free, and needs no account. This is a REST service you call from a server to generate artwork that does not exist yet. Different layer, different problem.
What can I build with an SVG generation API?
The cases that justify it are the ones where the artwork has to be per-something: a placeholder illustration per user, a cover image per article, an icon per tenant in a white-label product, or a bulk run over a spreadsheet of prompts. If the asset already exists in a catalogue, an icon API like Iconify is cheaper and faster.
How do I get access?
Sign in. The API is the same set of REST endpoints the dashboard uses, open to every signed-in account on any plan, and each generation spends credits exactly as it does in the dashboard. There are no separate API keys, no key screen and no versioned path yet — write to support@svgmakerai.com before you put it in production and we will show you how to use your account's token.
How does authentication work?
Your account's bearer token in the Authorization header on every authenticated request — the same token the dashboard sends. Public reads — fetching a published file or the gallery — need no token at all.
What comes back from a generation call?
JSON containing the stored record: the optimised SVG markup, the prompt it came from, the generation method, and an id you can use to fetch or delete it later.
How are credits consumed?
One per standard generation, two per premium. Storing, listing, fetching, publishing and deleting are free. Your balance is checked before any work starts.
Can I generate in batches?
Not as one call. There is no batch endpoint yet, so send one request per prompt; each one consumes credits at the usual rate, and only when it succeeds.
What are the limits?
Image uploads are capped at 10 MB and JSON bodies at 50 MB. Generation is inherently slower than a normal request, so treat these as long-running calls and set your timeouts accordingly.

Put vector generation in your own product.

Any signed-in account can call these endpoints with its own token, and each generation spends credits as it does in the dashboard. Tell us what you are building before it goes to production.

Email us about the API