Sandstorm API

Build on-brand ads into your product with one API.

One key runs image, video and voice models on your brand kit, reads your library and offers, and searches the ads your competitors run. A generation that fails costs nothing.

import { Sandstorm } from 'ads.dev'

const sandstorm = new Sandstorm()

const generation = await sandstorm.generations.run(
  'nano-banana-pro',
  {
    prompt: 'A ceramic mug on a sunlit bench',
    aspect_ratio: '4:5',
  },
)
console.log(generation.output[0]?.url)
200 OK
{
  "id": "gen_6c1f0e9a7b2d4c55a1e3f08b9d2c4e71",
  "model": "nano-banana-pro",
  "status": "succeeded",
  "output": [{
    "type": "image",
    "url": "https://cdn.sandstormapp.com/…/9c1e77aa.png",
    "width": 1856,
    "height": 2304
  }],
  "credits": 6
}

What you can build on

Everything Sandstorm knows about a brand, and every model it runs, over HTTP.

Generate on brandImages, video, voiceovers and music from one request shape. Name a model and its input is typed.
Read the brand kitVoice, audience, rules, colors, fonts and logos as JSON in one call, so what you make matches.
Offers with their photosThe products a brand sells, with variants, prices and photos from every angle, ready for image models.
The asset libraryList a brand's images, video and audio, or import a file. Every output is saved there with a permanent link.
Characters and voicesPeople, products and places kept consistent across shots, and ready-made voices for voiceovers.
Competitor adsFind an advertiser by name and read the ads it runs, filtered or searched by meaning.

Every model, priced per generation

Images, edits and upscales; video from text, images or references; voiceovers, music and sound effects. Name the model and it spends the same credits as the app.

Models
ImagesNano Banana, GPT Image, Seedream, Topaz
VideoSeedance, Kling, Gemini Omni, sync
AudioElevenLabs, MiniMax, Sonilo
Limits and billing
Billing$0.05 a credit
A failed generationFree
Requests300 a minute per key
Running at once1,000 per team
OutputsKept, with permanent links

Your first image in three steps

A key, one request, and a link to the finished file.

  1. 1Make a key in Sandstorm under Settings → API keys, or run the one-line login. Either way you get an sk_live_ key.
  2. 2POST /v1/generations with a model and its input. Send Prefer: wait=60 and the finished generation comes back in the same response.
  3. 3Use the output. Each one has a permanent link and an id you can pass straight into the next model.
One-line login
curl -fsSL https://ads.dev/login.mjs -o sandstorm-login.mjs && node sandstorm-login.mjs
Signs you in, makes a key and saves it to .env as SANDSTORM_API_KEY.

Questions

Do I need a Sandstorm account?

Yes. A key belongs to your Sandstorm team and acts on one of its brands, or on the brand each request names. Make one in Settings → API keys, or run the one-line login, which signs you in and saves the key to .env.

How is it billed?

Each generation spends your team's credits at $0.05 a credit, charged once it succeeds. Credits are held while it runs and released if it fails, or if you cancel it before the model starts. The API reference lists every model's price.

Which languages does it work with?

Any language that speaks HTTP. There are SDKs for TypeScript (npm install ads.dev) and Python (pip install ads_dev), and the OpenAPI document is at https://ads.dev/openapi.json.

How do I know when a video is done?

Wait for it in the same request with Prefer: wait, poll the generation, or pass a webhook_url and get generation.succeeded, generation.failed or generation.canceled, signed with your key's secret.

Can an AI agent use it?

Yes. https://ads.dev/llms.txt describes the API for agents, and the login command lets an agent make a key once you sign in. To work in Claude itself, the Sandstorm MCP server needs no key at all.

Build with Sandstorm.

Book a demo to plan your integration with the team, or read the API reference and make a key today.

Book a demoFor one marketer or the whole team.

More from Sandstorm