Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: Nano Studio Pro Sheets API
version: 1.0.0
description: 'Programmatic access to **Nano Studio Pro** — generate AI fashion and product photography, manage projects and assets, and track storage from any client (scripts, CLIs, AI agents).
### How it works
You group your work into **Projects**. Each generation belongs to a project. Reusable inputs (model photos, pose references, uploads) live in **Assets** and can be passed by ID into any generation. Generations cost credits by resolution (see `POST /v1/generations`); asset uploads count against your **storage quota**.
### Authentication
All requests require a Bearer token. Create one at Settings · API keys. The token is shown once at creation — store it safely. If lost, revoke and create a new one.
```bash
curl -H "Authorization: Bearer sk_sf_live_..." https://nanostudiopro.com/api/v1/me
```
Two kinds of key share this header:
- **Secret keys** (`sk_sf_live_...`) — full API access, governed by the token''s scopes. Never ship one in client-side code.
- **Publishable keys** (`pk_sf_live_...`) — safe to embed in public HTML. They are created with the `read` scope only and work **exclusively on `GET /v1/search`**: authentication itself rejects them with `401 unauthorized` on every other endpoint. Each publishable key optionally carries a **`search_scope`** object (see the schema of that name) that narrows what it can see:
- `projects` — the key sees only these project ids; absent = the whole library.
- `types` — result types the key may return (`asset` / `generation`).
- `max_image_size` — caps the `image_size` variant served; requests above the cap (the `preview` default included) are silently served the cap.
- `origins` — exact-match browser `Origin` allowlist; a request from any other origin gets `403 forbidden`. Absent = any origin. Requests with no Origin header (curl, server-to-server) always pass — the origin lock is a soft, browser-only control; the hard controls are the read-only scope and the narrowing above.
- `include_regions` — whether the key may request detection regions. Default false.
- `include_narrative` — whether results carry the AI-written photo description (`narrative`). Default false: publishable-key results omit it unless the scope opts in.
Scope narrowing is **silent by design**: a filter that falls entirely outside the key''s scope returns an empty 200 page, never an error, so a client can''t probe what exists outside its window.
### Rate limits
Per-token rate limits are enforced; when exceeded you''ll get `429` with a `Retry-After` header. Secret keys get **60 requests/min per token**. Publishable keys (search-only) get **600/min per key** plus **60/min per key + client IP** — whichever is stricter wins, so one hot visitor can''t exhaust a whole site''s key. Search rate limits are durable — shared across server instances, so counts don''t reset on deploys or split between replicas.
### Errors
All error responses use the same shape: `{ "error": { "code": "...", "message": "..." } }`. Common codes include `unauthorized`, `validation_error`, `not_found`, `insufficient_credits`, `token_cap_exceeded`, `storage_limit_exceeded`, `rate_limited`.
## Authorizing a device
Two ways to get a token:
1. **Manual** — create one in Settings · API Tokens. Returns a `sk_sf_live_...` token immediately.
2. **Device flow (RFC 8628)** — for CLIs and headless tools. Run `curl -fsSL https://nanostudiopro.com/cli/nsp -o /usr/local/bin/nsp && chmod +x /usr/local/bin/nsp && nsp login`, or implement the protocol yourself (full walkthrough at /docs/device-auth; endpoints are listed under the **Device Auth** tag below).
Each token can optionally have a **daily credit cap** — a rolling-24h spending limit independent of the wallet balance. Useful for limiting blast radius if a token leaks. Configure under Settings → API Tokens.'
contact:
url: https://nanostudiopro.com/settings?tab=api-tokens
servers:
- url: /api
description: Same origin as docs (auto-detects local vs prod)
- url: https://nanostudiopro.com/api
description: Production
security:
- BearerAuth: []
tags:
- name: Sheets
description: One image holding several separate elements laid out so each can be cut out — an animation cycle, a sprite sheet, an icon set, a sticker pack, a page of props. The server plans the grid, writes the prompt (an enumerated inventory with an asserted count, a keyable ground, no lines or labels, cells big enough to use) and records the recipe; you name what goes on it. `GET /v1/sheets/options` is the menu, `POST /v1/sheets` makes it (`dry_run` quotes), `GET /v1/sheets/{id}/atlas` tells an engine where the frames are.
paths:
/v1/sheets/options:
get:
tags:
- Sheets
summary: The menus a sheet is made from (free)
description: 'Everything that can be chosen by id, with one line each: the five kinds, the four keyable grounds, the art styles (photographic, drawn, painted), the animation sequences by subject (kind `frames`) or by game type (kind `sprites`) with frame counts per detail level (`id:key/smooth` or `id:key/full/smooth`), the levels, and the image models with their resolution ceilings. Built from the same catalogue the app''s page renders, so an agent and a person choose from one list.
Without parameters the index is about ten thousand characters and carries no frame text. With `family` and `type` it returns that one type''s sequences with their full frame lists at every level.'
parameters:
- name: family
in: query
schema:
type: string
description: A sequence family id from the index. Requires `type`.
- name: type
in: query
schema:
type: string
description: A type id within that family.
responses:
'200':
description: The index, or one type drilled down
'404':
description: No such family/type
operationId: getV1SheetsOptions
x-operation-id-source: derived
/v1/sheets:
post:
tags:
- Sheets
summary: Make a sheet of elements (credits)
description: 'Makes one sheet, server-side. Name the kind, then what goes on it: `sequences` by id from `/v1/sheets/options` (each `{family, type, id, level}`; `smooth` puts an in-between after every drawing and is the default), or `items` as plain descriptions, or both — sequences first, then items. For animation add `subject` (who is in every frame) and `art_style` (`photograph`, `film-still`, `studio-portrait`, `render-3d`, `stop-motion` for a real subject; `inked-cel`, `anime-cel`, `watercolour`… for a drawn one). Icons, stickers and props take a style too. Pixel sprites take none: pixel art is the style.
The server plans the grid (columns, rows, sheet shape, resolution) from the kind and the count, writes the prompt that makes sheets come back cuttable, and records the recipe — including the sequences, so the sheet''s atlas carries one animation tag each. **Never write this prompt yourself and never send it to `/v1/generations`.**
### Cost
One image at the planned tier: the `generate_*` rows of `GET /v1/pricing` for the chosen model (GPT Image reaches 2K only; the planner allows for it). The response carries `credits_cost` and `pricing_key`.
**Quote first.** `dry_run: true` runs every check and the planner and answers `200` with `status: quote`, the plan, the prompt and the price; nothing is generated or charged. The same body without it answers `201` with the generation.'
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- project_id
- kind
properties:
project_id:
type: string
kind:
type: string
enum:
- icons
- stickers
- sprites
- frames
- props
description: '`frames` = animation of one subject, real or drawn; `sprites` = 8/16-bit pixel art; the rest are matched sets.'
sequences:
type: array
description: Animations from `/v1/sheets/options`, in order. Several stack on one sheet.
items:
type: object
required:
- family
- type
- id
properties:
family:
type: string
type:
type: string
id:
type: string
level:
type: string
enum:
- key
- full
- smooth
default: smooth
items:
type: array
items:
type: string
description: Plain elements, one short description each (max 200 chars, 100 a sheet). Required when there are no sequences.
subject:
type: string
maxLength: 200
description: Who or what is in every frame. Ordered kinds only.
art_style:
type: string
description: A style id from the options. Every kind but `sprites`.
style:
type: string
maxLength: 2000
description: Your own words about the look, joined after `art_style`.
ground:
type: string
enum:
- black
- white
- green
- magenta
default: black
description: Pick the value NOT in the artwork.
border:
type: boolean
default: true
description: 'Stickers only: `false` leaves out the painted white die-cut border.'
model:
type: string
enum:
- gemini-nano-banana-2.1
- gemini-3-pro-image
- gpt-image-2.5-flare
- gpt-image-2.5-sunburst
default: gemini-nano-banana-2.1
per_row:
type: integer
description: Override the planned columns.
resolution:
type: string
enum:
- 1K
- 2K
- 4K
description: Override the planned tier; pulled down to the model's ceiling.
reference_ids:
type: array
items:
type: string
description: Sheets of the same thing to match; for `frames`, the subject to keep.
style_ids:
type: array
items:
type: string
description: Pictures whose look to borrow.
reference_note:
type: string
maxLength: 400
entity_ids:
type: array
items:
type: string
maxItems: 12
description: Saved characters, props or places (ids from `GET /v1/entities`) whose baked reference sheet to attach. Writing `@slug` in the prompt does the same — a look is `@parent/look` or its own slug — and the prompt is rewritten so the model knows which picture is whom. Sheets go after your own references, within the model's reference limit; the response's `entities` says which went in and which were dropped. Unknown `@words` are left as typed. To leave something out, write `-@slug` (that prop comes off every items sheet the request sends, and the words are removed from the prompt) or pass `-<id>` here; `@slug/alone` or `<id>/alone` sends the entity without its items sheet. The response's `entities.excluded` lists what was left out. Here `@slug` is read in `subject` and `reference_note`, and the sheet joins `reference_ids` as a matched reference.
dry_run:
type: boolean
default: false
responses:
'200':
description: '`dry_run`: `status: quote` with `plan`, `sequences`, `prompt`, `credits_cost`, `pricing_key`'
'201':
description: 'Answers once the image exists: `generation_id`, `task_id`, `status: completed`, the generation (`image_url`, `prompt_used`, `model`, `credits_remaining`, …) plus `plan`, `sequences`, `credits_cost`, `pricing_key`'
'400':
description: validation_error — unknown kind, model, art_style or sequence (the message names what exists)
'402':
description: insufficient_credits or token_cap_exceeded
'404':
description: Project not found
operationId: postV1Sheets
x-operation-id-source: derived
/v1/sheets/plan:
post:
tags:
- Sheets
summary: Plan a sheet and get its prompt (free)
description: 'The prompt-only door: the same body as `POST /v1/sheets`, answered with the plan, the prompt, `aspect_ratio`, `resolution`, `model` and `credits_cost`, for generating elsewhere. Prefer `POST /v1/sheets`, which keeps the prompt server-side. `GET` returns the same index as `/v1/sheets/options`.'
responses:
'200':
description: prompt, aspect_ratio, resolution, model, layout, sequences, warnings, credits_cost
operationId: postV1SheetsPlan
x-operation-id-source: derived
/v1/sheets/{id}/atlas:
get:
tags:
- Sheets
summary: A sheet's frame rects and animation tags (free)
description: 'For a sheet you own: every frame''s pixel rect, the per-frame registration, fps, pivot and one animation tag per recorded sequence, as Aseprite-format JSON (Phaser, Pixi, Godot and Unity import it). The rects describe the file as it is; corrections are reported under `meta.nsp` rather than folded into them. `meta.nsp.labels` lists what each cell was asked for, in frame order (absent on a sheet adopted from an existing picture). `409` when the image is not a sheet.'
parameters:
- name: id
in: path
required: true
schema:
type: string
description: The sheet's generation id.
responses:
'200':
description: Aseprite-format atlas JSON
'404':
description: Not found
'409':
description: Not a sheet, or no grid / pixel size recorded
operationId: getV1SheetsByIdAtlas
x-operation-id-source: derived
/v1/sheets/{id}/pieces:
get:
tags:
- Sheets
summary: A sheet cut into transparent PNGs, one per cell (free)
description: 'For a sheet you own: the ground keyed out and every cell cut into its own transparent PNG, trimmed to its drawing, by the editor''s rules. `grow` gives a drawing that runs past its cell the room it needs; `clean` (the editor''s "Only this") drops anything a neighbour pushes into the frame, keeping what sits wholly inside. Each piece carries `label` (what the cell asked for), `image_url` (expires like every image link; ask again for a fresh one), its size, and `sheet_rect` (where it sits on the sheet). An empty cell answers `empty: true` and no link. Cut once: asking again serves the same files. Counts against storage. `409` when the image is not a sheet or its ground is not one flat colour; `ground` reports how the key went (`clean`, `soft` = an edge still tinted, `unjudged` = black or white ground, `clear` = already transparent).'
parameters:
- name: id
in: path
required: true
schema:
type: string
description: The sheet's generation id.
- name: grow
in: query
schema:
type: boolean
default: true
- name: clean
in: query
schema:
type: boolean
default: true
responses:
'200':
description: '`generation_id`, `ground`, `count`, `pieces[]`: `index`, `label`, `image_url`, `width`, `height`, `sheet_rect`, `cell`, `grown`, `cleaned`, `empty`'
'404':
description: Not found
'409':
description: Not a sheet, no grid recorded, or no flat ground to key
operationId: getV1SheetsByIdPieces
x-operation-id-source: derived
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: 'Personal access token from `/settings?tab=api-tokens`. Send as `Authorization: Bearer sk_sf_live_...` — or a publishable `pk_sf_live_...` key, which authenticates on `GET /v1/search` only.'