Shader
Generate a file

DocsGuides17 of 35 · 3 min read

Generate a file

Make an image, a video, a voice track or a 3D asset for a price in credits shown before it starts.

A generation runs one job on the provider configured by the operator and charges it once, when its file is stored (Metering and settlement). You need credits that cover its estimate, or a wallet with USDC to pay over x402 instead.

#Prices and options

KindCreditsPerIn dollars
Image40image$0.040
Video100output second$0.100
Voice151,000 characters$0.015
3D asset2003D asset$0.200

A 5-second video costs 500 credits, $0.50. Voice is counted per character, 0.015 credits each, so 2,500 characters cost 37.5 credits.

KindOptions
Imagewidth and height 256 to 2048, count 1 to 4, format png or webp
VideooutputSeconds 1 to 60, required; aspectRatio 16:9, 9:16 or 1:1; format mp4 or webm
Voicethe text to speak, up to 4,096 characters per request; voice; format mp3 or wav
3D assetformat glb or usdz; style

The full request shapes are under GenerationRequest.

#Generate

App

  1. Pick the kind

    Open Create and pick the Kind: image, video, voice or 3D asset.

  2. Write the prompt

    Write the prompt, or for voice the text, and set the options. The cost in credits updates as you type.

  3. Generate

    Press Generate. The job runs in Results with its progress.

  4. Get the file

    When it is done, download the file from Results; its receipt links from it.

SDK

generate.ts
const estimate = await shader.estimate({ kind: 'image', prompt: 'a lighthouse at dusk' })
const job = await shader.generate({ kind: 'image', prompt: 'a lighthouse at dusk' })
const done = await shader.waitForJob(job.id)

done.result holds the file's URL, type and size, and done.receipt its receipt.

CLI

Terminal
shader estimate image "a lighthouse at dusk"
shader generate image "a lighthouse at dusk" --out lighthouse.png

generate waits for the job and saves the file to --out. --seconds sets a video's length and --voice the voice.

MCP

Call generate with kind, prompt and options, then get_job until it is done. A video without outputSeconds runs for 4 seconds.

#What happened

  1. Admission

    The API checked that your available credits cover the estimate and, for an agent, the key's caps.

  2. Reservation

    It reserved the estimate against other work while the job ran.

  3. The job

    The job ran on the provider configured by the operator, from queued to running to done.

  4. Settlement

    Once the file was stored, the backend settled the job in one line of kind generation.

#The receipt

One generation receipt per job, with the job's units (images, output seconds, characters or assets) and the credits charged.

#If it fails

What you seeWhyNext
failed, "Not charged."The provider did not produce a fileNothing was charged. Generate again
CREDITS_TOO_LOWAvailable credits do not cover the estimateDeposit
AGENT_CAP_EXCEEDED, AGENT_DAILY_CAP_EXCEEDEDThe estimate is above the key's per-request cap or what is left of its dayMake the job smaller or raise the cap
CONFIGURATION_REQUIREDNo provider is configured for this kindThe operator configures one
VALIDATION_ERRORAn option is out of rangeFix the field the error names