Overview
The LazySusan API gives you 18 chat models, 26 image models and 12 video models behind one key, and the list keeps growing. Use our SDKs for JavaScript/TypeScript and Python, or call the HTTP API from any language. Every model in a category takes the same request, so switching models is a one-string change.
| Endpoint | SDK | What it does |
|---|---|---|
| POST /chat/completions | chat.create · chat.stream | Chat with any chat model. Streaming, images in, function calling and JSON output. |
| POST /images/generations | images.generate | Generate images. Returns hosted URLs or base64. |
| POST /videos | videos.create | Start a video. It runs in the background. |
| GET /videos/{id} | videos.get · videos.wait | Check a video and get its URL when it's done. |
| GET /videos | videos.list | Your 50 most recent videos. |
| GET /models | models.list · models.get | Every model with its limits and price. No key needed. |
| GET /credits | credits.get | Your team's remaining balance. |
You pay from a prepaid balance of credits shared by your team. One credit is $0.001, so $25 buys 25,000 credits. Every request is billed for what it actually used, and requests that fail aren't charged. No subscription is needed.
Quickstart
- Create an account in the developer console. No subscription needed.
- Buy credits (packs start at $25).
- Create a key and copy it: it's shown once. Save it as
LAZYSUSAN_API_KEY. - Install the SDK and send your first request:
// npm install lazysusan
import LazySusan from "lazysusan";
const ls = new LazySusan(); // reads LAZYSUSAN_API_KEY
const r = await ls.chat.create({
model: "anthropic/claude-sonnet-5-5",
messages: [{ role: "user", content: "Write a haiku about lazy susans." }],
});
console.log(r.text);
console.log(r.usage.costCredits, "credits");Every response tells you what the request cost in credits. Working on a team? Have an owner or admin invite you and create your key under the team, so your usage is tracked there.
SDKs
Our SDKs wrap the HTTP API with typed requests and responses, streaming, video polling, retries and clear errors. They have no dependencies.
| Language | Install | Runs on |
|---|---|---|
| JavaScript / TypeScript | npm install lazysusan | Node 18+, Bun, Deno and edge runtimes. Types included. |
| Python | pip install lazysusan | Python 3.9+. |
Configuration
The client reads LAZYSUSAN_API_KEY from the environment. You can also pass the key, a timeout and the number of retries:
const ls = new LazySusan({
apiKey: process.env.MY_KEY,
timeoutMs: 60_000, // default 300000
maxRetries: 3, // default 2
});The SDK retries only requests that were never charged: rate limits and models that are briefly unavailable. Keep keys on your server; never ship them in browser or mobile app code.
Switching models
for (const model of ["openai/gpt-6.1-sol", "anthropic/claude-opus-5-5", "google/gemini-3.8-flash", "xai/grok-4.7"]) {
const r = await ls.chat.create({
model,
messages: [{ role: "user", content: "Summarise our refund policy in one sentence." }],
maxTokens: 400,
});
console.log(model, r.usage.costCredits, r.text);
}Tagging requests
Add metadata to any chat, image or video call to label it. Tags are stored with the request's usage record, so you can filter the console's charts and request log by them.
await ls.chat.create({
model: "google/gemini-3.8-flash",
messages,
metadata: { project: "checkout", feature: "summaries", customer: "acme" },
});Up to 16 tags per request. Keys are 1–40 letters, digits or _ . : -; values are strings of up to 200 characters. Don't put secrets or personal data in tags.
Authentication and keys
The SDK sends your key for you. Over HTTP, send it on every request as Authorization: Bearer lsk_live_… (the x-api-key header works too). Keys are lsk_live_ followed by 40 letters and digits.
Each key belongs to a person on your team and can carry its own settings:
| Setting | What it does |
|---|---|
| Name and description | So you know what it's for later. |
| Project | Groups usage in the dashboard, for example checkout or support-bot. |
| Environment | production, staging, development or test. Filter usage by it. |
| Monthly budget | Most credits the key can spend in a calendar month. Past it, requests get 402 key_budget_reached. |
| Allowed models | Only these models can be called with the key. Anything else gets 403 model_not_allowed. |
| Expiry | The key stops working on this date (401 api_key_expired). |
- Use one key per service and environment, so you can revoke one without breaking the others.
- Revoking a key takes effect on the next request.
- We store only a one-way hash of each key, so a lost key can't be shown again. Create a new one.
- A team can have up to 200 active keys. Revoked keys don't count.
Teams and roles
Every API account is a team, and whoever creates it is its owner. Invite as many people as you need, up to 100 members including pending invites. Everyone shares one balance, while each person keeps their own keys and their own usage.
| Role | Can do |
|---|---|
owner | Everything, including billing. One per team: the person who created it. |
admin | Everything except transferring or deleting the account: invite and remove members, change roles, manage every key, alerts and billing. |
developer | Create, edit and revoke their own keys. See usage for their own keys only. |
viewer | Read-only: all usage, keys and alerts across the team. Good for finance or a project manager. |
Inviting people
- In the console, open Team, enter one or more email addresses and pick a role.
- Each person gets an email with a one-click link. Links expire after 7 days; resend from the console if one lapses.
- New to LazySusan? Clicking the link creates their account and signs them in. Already have an account? They sign in and join. No subscription is needed either way.
A person can belong to several teams and switch between them in the console. Keys always belong to one team, and usage is billed to that team's balance.
Managing members
| Action | Effect |
|---|---|
| Change role | Takes effect immediately in the console. |
| Monthly budget | Caps what the person can spend across all their keys each month. Past it, their requests get 402 member_budget_reached. |
| Allowed models | Limits the person to a list of models on every key they own. A key's own list can narrow it further, never widen it. |
| Suspend | All their keys stop working at once (403 member_suspended). Unsuspend to restore them. |
| Remove | Takes them off the team and revokes every key they own. |
Audit log
Owners and admins see a log of every change: invites, joins, removals, role changes, suspensions, keys created, edited or revoked, budget and allowed-model changes, alerts, settings and credit purchases, each with who did it and when.
Usage and analytics
The console's dashboard shows spend, requests, tokens, errors and latency for any date range up to a year, by hour or by day. Break it down by:
- member (who made the requests)
- key
- project and environment
- model and provider
- endpoint (chat, images, videos)
Every filter applies to the chart, the breakdowns and the request log at once. Owners, admins and viewers see the whole team; developers see their own keys.
Request log
Every request is listed with its time, key, member, model, status, tokens, cost and latency. Search by request id (gen-…, img-…, vid-…), filter by status or by a metadata tag such as feature=summaries, and export the filtered list as CSV (up to 50,000 rows).
Alerts
Owners and admins can set email alerts. Each alert has a condition and up to 10 addresses to notify:
| Alert | Fires when |
|---|---|
balance_below | The team's balance drops below a number of credits. |
daily_spend_above | Spend today passes a number of credits. |
monthly_spend_above | Spend this month passes a number of credits. |
key_budget_used | Any key has used more than a percentage of its monthly budget. |
error_rate_above | More than a percentage of requests in the last hour failed (at least 20 requests). |
Alerts are checked every 5 minutes. Each one emails once when its condition starts, then waits until the condition clears before it can fire again. A team can have up to 50 alerts.
Models and prices
Model ids are provider/model, for example openai/gpt-6.1-sol or google/veo-3.1-fast. Prices are in credits ($0.001 each). The same list, with every limit, is available from ls.models.list() or GET https://www.lazysusan.ai/api/v1/models (no key needed), and GET /models/{provider}/{model} for a single model.
Chat models
Priced per million tokens. Output includes any reasoning (“thinking”) tokens the model uses.
| Model id | Context | Max output | Input / 1M | Output / 1M | Images in |
|---|---|---|---|---|---|
| openai/gpt-6.1-sol | 400K | 64,000 | 2,300 | 11,500 | yes |
| openai/gpt-6-astra | 400K | 64,000 | 11,500 | 57,500 | yes |
| openai/gpt-6-luna | 400K | 64,000 | 115 | 575 | yes |
| anthropic/claude-fable-5-1 | 1,000K | 64,000 | 11,500 | 57,500 | yes |
| anthropic/claude-opus-5-5 | 1,000K | 64,000 | 4,600 | 23,000 | yes |
| anthropic/claude-sonnet-5-5 | 1,000K | 64,000 | 2,300 | 11,500 | yes |
| anthropic/claude-haiku-5-5 | 1,000K | 64,000 | 115 | 575 | yes |
| google/gemini-3.1-pro | 1,000K | 65,536 | 2,300 | 13,800 | yes |
| google/gemini-3.8-flash | 1,000K | 65,536 | 862.5 | 4,312.5 | yes |
| google/gemini-3.5-flash-lite | 1,000K | 65,536 | 345 | 2,875 | yes |
| xai/grok-4.7 | 1,000K | 32,768 | 2,300 | 6,900 | yes |
| xai/grok-4.3 | 1,000K | 32,768 | 1,437.5 | 2,875 | yes |
| xai/grok-build-0.1 | 1,000K | 32,768 | 1,150 | 2,300 | yes |
| deepseek/deepseek-flash | 128K | 8,192 | 345 | 1,380 | no |
| deepseek/deepseek-v4-pro | 128K | 8,192 | 1,518 | 4,554 | no |
| perplexity/sonar | 127K | 8,192 | 2,300 | 2,300 | no |
| perplexity/sonar-pro | 127K | 8,192 | 6,900 | 34,500 | no |
| perplexity/sonar-reasoning-pro | 127K | 8,192 | 4,600 | 18,400 | no |
Cached input (where a repeated prompt prefix is cached) is billed at the lower cached rate shown in GET /models. Long prompts on some models are billed at a higher tier: Claude Haiku 5.5 above 100K input tokens, Gemini 3.1 Pro above 200K and Grok above 200K. Perplexity Sonar models run a live web search on every request; the search adds a per-request fee and search-result tokens, which are included in the request's cost.
Image models
| Model id | Sizes | Price per image | Max n | Input images |
|---|---|---|---|---|
| google/nano-banana-2.1 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 38.64 | 4 | yes |
| google/nano-banana-pro | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 154.1 | 4 | yes |
| openai/gpt-image-2.5 | 1024x1024, 1536x1024, 1024x1536 | by usage: typically 5.635 (low), 19.435 (medium), 48.415 (high) | 4 | no |
| openai/gpt-image-2.5-fast | 1024x1024, 1536x1024, 1024x1536 | by usage: typically 5.635 (low), 19.435 (medium), 48.415 (high) | 4 | no |
| bfl/flux-2-pro | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 57.5 | 1 | no |
| bfl/flux-3 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 55.2 | 1 | no |
| bfl/flux-kontext-pro | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 46 | 1 | no |
| bfl/flux-kontext-max | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 92 | 1 | no |
| bfl/flux-pro-1.1 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 46 | 1 | no |
| bfl/flux-pro-1.1-ultra | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 69 | 1 | no |
| xai/grok-imagine-image | 1024x1024 | 23 | 4 | no |
| xai/grok-imagine-image-quality | 1024x1024 | 57.5 | 4 | no |
| xai/grok-imagine-image-2.0 | 1024x1024 | 69 | 4 | no |
| midjourney/v7 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 92 | 1 | no |
| midjourney/v6.1 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 46 | 1 | no |
| midjourney/v6 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 46 | 1 | no |
| midjourney/niji-6 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 57.5 | 1 | no |
| stability/sd-3.5-large | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 92 | 1 | no |
| stability/sd-3.5-medium | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 46 | 1 | no |
| stability/sdxl | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 46 | 1 | no |
| stability/sd-turbo | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | 57.5 | 1 | no |
| ideogram/ideogram-3 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184, 1248x832, 832x1248 | see GET /models | 1 | no |
| recraft/recraft-v3 | 1024x1024, 1280x1024, 1024x1280, 1536x1024, 1024x1536 | 46 | 1 | no |
| recraft/recraft-v3-vector | 1024x1024, 1280x1024, 1024x1280, 1536x1024, 1024x1536 | 92 | 1 | no |
| luma/photon-1 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184 | 17.25 | 1 | no |
| luma/photon-flash-1 | 1024x1024, 1344x768, 768x1344, 1184x864, 864x1184 | 4.6 | 1 | no |
GPT Image models are billed by the tokens each image actually uses (34,500 credits per 1M image output tokens, 5,750 per 1M prompt tokens), so the figures above are typical, not fixed. A request reserves the most an image of that size and quality could use and is charged only what it used. Larger sizes and higher quality use more tokens.
Video models
| Model id | Seconds | Resolution | Aspect ratio | Price per video | Notes |
|---|---|---|---|---|---|
| google/veo-3.1 | 4, 6, 8 | 720p, 1080p | 16:9, 9:16 | 720p · 4s: 1,840; 720p · 6s: 2,760; 720p · 8s: 3,680; 1080p · 8s: 3,680 | includes audio |
| google/veo-3.1-fast | 4, 6, 8 | 720p, 1080p | 16:9, 9:16 | 720p · 4s: 460; 720p · 6s: 690; 720p · 8s: 920; 1080p · 8s: 1,104 | includes audio |
| google/veo-3.1-lite | 4, 6, 8 | 720p, 1080p | 16:9, 9:16 | 720p · 4s: 230; 720p · 6s: 345; 720p · 8s: 460; 1080p · 8s: 736 | includes audio |
| runway/gen-4.5 | 5, 10 | 720p | 16:9, 9:16 | 720p · 5s: 690; 720p · 10s: 1,380 | — |
| runway/gen-4-turbo | 5, 10 | 720p | 16:9, 9:16 | 720p · 5s: 287.5; 720p · 10s: 575 | needs a starting image |
| luma/ray-2 | 5, 9 | 540p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 | 540p · 5s: 460; 540p · 9s: 828; 720p · 5s: 816.5; 720p · 9s: 1,469.7; 1080p · 5s: 989; 1080p · 9s: 1,780.2 | — |
| luma/ray-flash-2 | 5, 9 | 540p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 | 540p · 5s: 161; 540p · 9s: 289.8; 720p · 5s: 276; 720p · 9s: 496.8; 1080p · 5s: 448.5; 1080p · 9s: 807.3 | — |
| pika/pika-2.5 | 5, 9 | 540p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 | 540p · 5s: 460; 540p · 9s: 828; 720p · 5s: 816.5; 720p · 9s: 1,469.7; 1080p · 5s: 989; 1080p · 9s: 1,780.2 | — |
| pika/pika-2.2 | 5, 9 | 540p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 | 540p · 5s: 460; 540p · 9s: 828; 720p · 5s: 816.5; 720p · 9s: 1,469.7; 1080p · 5s: 989; 1080p · 9s: 1,780.2 | — |
| pika/pika-turbo | 5, 9 | 540p, 720p, 1080p | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 | 540p · 5s: 161; 540p · 9s: 289.8; 720p · 5s: 276; 720p · 9s: 496.8; 1080p · 5s: 448.5; 1080p · 9s: 807.3 | — |
| vidu/viduq2-pro | 4, 5, 8 | 540p, 720p, 1080p | 16:9, 9:16, 1:1 | 540p · 4s: 143.75; 540p · 5s: 172.5; 540p · 8s: 258.75; 720p · 4s: 258.75; 720p · 5s: 316.25; 720p · 8s: 488.75; 1080p · 4s: 575; 1080p · 5s: 661.25; 1080p · 8s: 920 | — |
| vidu/viduq2-turbo | 4, 5, 8 | 540p, 720p, 1080p | 16:9, 9:16, 1:1 | 540p · 4s: 69; 540p · 5s: 80.5; 540p · 8s: 115; 720p · 4s: 218.5; 720p · 5s: 276; 720p · 8s: 448.5; 1080p · 4s: 373.75; 1080p · 5s: 431.25; 1080p · 8s: 603.75 | needs a starting image |
Chat
ls.chat.create(…) · POST https://www.lazysusan.ai/api/v1/chat/completions
Parameter names below are as sent over HTTP. The Python SDK uses the same names; the JavaScript SDK uses camelCase (maxTokens, responseFormat, toolChoice).
| Parameter | Type | Notes |
|---|---|---|
model | string, required | A chat model id from the table above. |
messages | array, required | 1–2,000 messages. Roles: system, developer, user, assistant, tool. content is a string or an array of parts ({type:"text",text} and {type:"image_url",image_url:{url,detail?}}). Assistant messages may have content null with tool_calls. Tool messages need tool_call_id. An optional name is kept (up to 64 characters). |
max_tokens | integer | Most tokens to generate, including reasoning tokens. max_completion_tokens is accepted as an alias. Up to the model's max output. Default 4,096; if your balance can't cover that and you didn't set it, the request runs with 1,024. |
temperature | number 0–2 | Ignored by OpenAI GPT-6 models. |
top_p | number 0–1 | Ignored by OpenAI GPT-6 models. |
presence_penalty | number −2–2 | Ignored by OpenAI GPT-6 models. |
frequency_penalty | number −2–2 | Ignored by OpenAI GPT-6 models. |
seed | integer | Best-effort determinism where the model supports it. |
stop | string or string[] | Up to 4 stop sequences. |
tools | array | Up to 128 function tools: {type:"function", function:{name, description?, parameters?}}. Other tool types (for example built-in web search) are rejected. |
tool_choice | string or object | auto, none, required, or a specific function. |
parallel_tool_calls | boolean | |
response_format | object | {type: "text" | "json_object" | "json_schema", …}. |
metadata | object | Up to 16 string tags for filtering usage. See Tagging requests. |
stream | boolean | HTTP only: stream tokens as server-sent events. In the SDK, use chat.stream. See Streaming. |
stream_options | object | HTTP only: {include_usage: true} adds a final chunk with usage and cost. |
n | integer | Only 1 is supported; any other value is rejected. |
Unknown parameters are ignored rather than rejected. Reasoning models (GPT-6, Gemini 3.x, Grok, DeepSeek V4 Pro, Sonar Reasoning Pro) spend part of max_tokens thinking before they answer. With a very small limit they can return an empty answer with a finish reason of length: leave room, a few hundred tokens or more.
Response
The SDK gives you text, toolCalls / tool_calls, finishReason / finish_reason, usage (input, output and cached tokens plus credits charged) and the requestId / request_id. Over HTTP the body is:
{
"id": "gen-6f0c2a5e-1d2b-4c7e-9a51-0b8f3c2d7e14",
"object": "chat.completion",
"created": 1791676800,
"model": "anthropic/claude-sonnet-5-5",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Turns once, then rests…" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 22,
"total_tokens": 40,
"cost_credits": 0.295
}
}usage.completion_tokens includes reasoning tokens. usage.prompt_tokens_details.cached_tokens appears when part of the prompt was cached. Perplexity models also return citations and search_results. Every response carries an x-request-id header with the same id as the body.
Streaming
ls.chat.stream(…) takes the same parameters as chat.create and yields the reply as it's generated. The last event carries the full text and the usage, including the credits charged.
const stream = ls.chat.stream({
model: "openai/gpt-6-luna",
messages: [{ role: "user", content: "Count from 1 to 5." }],
});
for await (const ev of stream) {
if (ev.type === "delta") process.stdout.write(ev.text);
if (ev.type === "done") console.log("\ncost:", ev.usage?.costCredits, "credits");
}Over HTTP, each event is a data: line holding a chat.completion.chunk, and the stream ends with data: [DONE]. With "stream_options": {"include_usage": true}, one more chunk with an empty choices array and the request's usage arrives just before [DONE].
If you disconnect mid-stream, the request stops and you're billed for the prompt and the output generated up to that point. If a provider fails mid-stream, the SDK raises an error; over HTTP you get a final event of the form {"error": {"message", "type": "upstream_error"}} and the stream closes without [DONE].
Images in, tools and JSON
Images in a prompt
Models with “Images in: yes” accept up to 20 images per request as image_url parts. Use a public https:// URL or a base64 data:image/(png|jpeg|webp|gif);base64,… URL. detail may be low, high or auto.
await ls.chat.create({
model: "google/gemini-3.8-flash",
messages: [{
role: "user",
content: [
{ type: "text", text: "What's in this photo?" },
{ type: "image_url", image_url: { url: "https://example.com/photo.jpg" } },
],
}],
});Function calling
const tools = [{
type: "function",
function: {
name: "get_order_status",
description: "Look up an order by id",
parameters: { type: "object", properties: { order_id: { type: "string" } }, required: ["order_id"] },
},
}];
const messages = [{ role: "user", content: "Where is order A-1042?" }];
const first = await ls.chat.create({ model: "openai/gpt-6.1-sol", messages, tools });
const call = first.toolCalls[0];
// …run your function, then send the result back:
const second = await ls.chat.create({
model: "openai/gpt-6.1-sol",
messages: [...messages, first.message, { role: "tool", tool_call_id: call.id, content: '{"status": "shipped"}' }],
tools,
});JSON output
Set response_format (responseFormat in JavaScript) to {"type": "json_object"}, or json_schema with a schema, on models that support it. If a model doesn't, the request is rejected with a 400 and you aren't charged.
Images
ls.images.generate(…) · POST https://www.lazysusan.ai/api/v1/images/generations
| Parameter | Type | Notes |
|---|---|---|
model | string, required | An image model id. |
prompt | string, required | Up to 4,000 characters. |
n | integer | Default 1, up to the model's Max n (FLUX: 1; Nano Banana, GPT Image and Grok Imagine: 4). |
size | string | One of the model's sizes, e.g. 1024x1024 (the default) or 1344x768. Nano Banana and FLUX map sizes to aspect ratios. |
quality | string | GPT Image only: low, medium (default) or high. auto and standard mean medium; hd means high. |
response_format | string | url (default): a permanent hosted URL. b64_json: the image inline as base64. In the SDK this is format. |
image | string | Nano Banana models only: an image to edit or use as a reference (https URL or data: URL, PNG/JPEG/WebP, up to 20 MB). Or send up to 3 as images: []. |
metadata | object | Up to 16 string tags for filtering usage. |
const img = await ls.images.generate({
model: "google/nano-banana-2.1",
prompt: "A red ceramic cube on a white table, studio light",
size: "1344x768",
});
console.log(img.images[0].url, img.usage.costCredits);You're charged only for images actually delivered: if you ask for 4 and 3 come back, you pay for 3. If no image comes back (for example the prompt was declined by a safety filter) the request returns 400 and costs nothing. Hosted URLs stay up and are unguessable; anyone with the URL can open it, so treat it like a share link. In the rare case hosting is unavailable, an item comes back as base64 even if you asked for a URL.
Videos
Video takes from about a minute to a few minutes, so it runs in the background. ls.videos.create(…) starts it and returns straight away; ls.videos.wait(id) polls until it's done and returns the finished video, or raises an error if it failed (you aren't charged for a failure).
const v = await ls.videos.create({
model: "google/veo-3.1-fast",
prompt: "A slow pan across a calm lake at sunrise",
seconds: 8,
resolution: "1080p",
});
const done = await ls.videos.wait(v.id);
console.log(done.videoUrl, done.costCredits);| Parameter | Type | Notes |
|---|---|---|
model | string, required | A video model id. |
prompt | string, required | Up to 2,000 characters. |
seconds | integer | One of the model's durations. Default: the shortest. |
resolution | string | One of the model's resolutions. Default: the first listed. Veo renders 1080p only at 8 seconds. |
aspect_ratio | string | 16:9 (default) or 9:16. aspectRatio in JavaScript. |
image | string | Starting frame (https or data: URL, PNG/JPEG/WebP, up to 20 MB). Required for runway/gen-4-turbo. |
negative_prompt | string | Google Veo models only. Up to 1,000 characters. negativePrompt in JavaScript. |
metadata | object | Up to 16 string tags for filtering usage. |
{
"id": "vid-91c4…",
"object": "video",
"model": "google/veo-3.1-fast",
"status": "succeeded",
"created": 1791676800,
"completed": 1791676911,
"seconds": 8,
"resolution": "1080p",
"aspect_ratio": "16:9",
"video_url": "https://…/api/…/91c4…-0.mp4",
"cost_credits": 1104
}- Starting a video holds its exact price from your balance while it renders (
cost_credits_held). - On success you're charged that amount. On failure, the status is
failed,error.messagesays why, and the hold is returned in full. - A video that hasn't finished after 2 hours is marked failed and refunded.
- Videos finish even if you stop waiting;
ls.videos.list()returns your 50 most recent. The video URL is permanent and unguessable.
Credits and billing
The API runs on a prepaid balance shared by everyone on the team. One credit is $0.001. Nothing is billed in arrears: a request only runs if the balance can cover it. Credits don't expire.
Buying credits
| Pack | Credits |
|---|---|
| $25 | 25,000 |
| $100 | 100,000 |
| $500 | 500,000 |
| $2,000 | 2,000,000 |
Owners and admins buy packs, or any amount from $25 to $5,000, in the console with a card. Every purchase has a receipt in the console. New accounts can add up to $250 a day for their first week; after that, up to $5,000 a day.
Automatic top-up
Turn on auto top-up to never run dry: when your balance falls below a threshold you choose (1,000 to 10,000,000 credits), we charge the card you last paid with for an amount you choose ($25 to $5,000) and add the credits straight away. It needs one manual purchase first, so there's a card on file. After 3 declined charges in a row, auto top-up switches itself off.
Spend limits
Three limits, which all apply. A request that would go past any of them is refused with 402 before it runs:
| Limit | Set on | Error code |
|---|---|---|
| Monthly limit | The whole team (Settings) | monthly_limit_reached |
| Member budget | One person, across all their keys (Team) | member_budget_reached |
| Key budget | One key (Keys) | key_budget_reached |
Credits held by requests in progress count toward each limit. Budgets reset at the start of each calendar month (UTC).
How a request is billed
- Before a request runs, we hold the most it could cost: the full prompt plus
max_tokensof output for chat, the per-image price × n for images, the clip price for video. - We run it, and the model reports exactly what was used.
- You're charged for actual usage (never more than the hold), and the rest of the hold is released immediately.
Holds mean many requests can run at once without ever overdrawing your balance. A large max_tokens on an expensive model needs a bigger balance to start, even though you're only charged for what's used. Requests rejected before they reach a model, and requests the provider fails, cost nothing.
Checking your balance
const { balance, autoTopUp } = await ls.credits.get();Errors
The SDKs raise LazySusanError with status, code, message and requestId (request_id in Python), so you can branch on the code:
import LazySusan, { LazySusanError } from "lazysusan";
try {
await ls.chat.create({ model, messages });
} catch (err) {
if (err instanceof LazySusanError && err.code === "key_budget_reached") {
// this key is out of budget for the month
}
console.error(err.status, err.code, err.message, err.requestId);
}| Status | Codes | What to do |
|---|---|---|
| 400 | invalid_json, invalid_request, invalid_metadata, model_not_found, images_not_supported, invalid_image, image_unreachable, image_too_large, image_required, context_length_exceeded, provider_rejected_request, no_image | Fix the request; param names the field. provider_rejected_request means the model refused it (for example a safety filter); you weren't charged. |
| 401 | missing_api_key, invalid_api_key, api_key_expired | Check the key and the Authorization header, or create a new key. |
| 402 | insufficient_balance, monthly_limit_reached, member_budget_reached, key_budget_reached | Add credits, lower max_tokens, or raise the limit in the console. |
| 403 | model_not_allowed, member_suspended, account_suspended | Use a model the key allows, or ask a team admin. |
| 404 | model_not_found, video_not_found | Check the id. |
| 405 | method_not_allowed | Use POST for chat, images and starting videos. |
| 413 | request_too_large | Send a smaller body (see Limits). |
| 429 | rate_limited | Wait for the Retry-After seconds, then retry. The SDK does this for you. |
| 500 | server_error | Retry; if it persists, send us the request id. |
| 502 | provider_error, provider_unreachable | The model failed to respond. Retry, or switch models. You weren't charged. |
| 503 | model_unavailable, provider_rate_limited | The model is briefly unavailable or busy. Retry after Retry-After, or switch models. You weren't charged. |
Responses include an x-request-id header (gen-…, img-… or vid-…) whenever a request got far enough to be billed. Search for it in the console's request log.
Rate limits and limits
| Limit | Value |
|---|---|
| Requests per key | 120 per minute |
| Requests per team | 600 per minute, across all keys |
| Members per team | 100, including pending invites |
| Active keys per team | 200 |
| Alerts per team | 50 |
| Chat request body | 8 MB |
| Image request body | 64 MB |
| Video request body | 32 MB |
| Messages per chat request | 2,000 |
| Images in a chat request | 20 |
| Input images for image models | 3, each up to 20 MB |
| Image prompt | 4,000 characters |
| Video prompt | 2,000 characters |
| Metadata tags per request | 16 |
Over the rate limit you get 429 with a Retry-After header. Spread heavy traffic across keys, one per service. Repeated requests with invalid keys from one address are also rate limited.
Data and security
- All traffic is HTTPS. Keys are stored only as one-way hashes and shown once.
- We don't store your prompts or the text models send back, and we don't train on them. We keep a usage record per request (model, key, token counts, cost, latency, tags, time) for billing and your dashboard.
- Generated images and videos are hosted at unguessable URLs so you can use them directly. Download and re-host them if you need to control access.
- Image URLs you send us are fetched only from the public internet; private and internal addresses are refused.
- Team changes, key changes and purchases are recorded in the audit log.
Changelog
| Date | Change |
|---|---|
| 2026-10-11 | JavaScript and Python SDKs. Teams with owner, admin, developer and viewer roles and one-click invites. Per-key and per-member budgets, allowed models and key expiry. Usage analytics, request log with CSV export, request tags, email alerts and an audit log. |
| 2026-10-11 | Launch: chat, image and video models; prepaid credits, auto top-up and monthly limits. |
Support
Something look wrong? Email support@lazysusan.ai with the request id (x-request-id).