# Nano Studio Pro > AI image generation and editing platform with a public REST API. Authenticated users get a CLI (`nsp`), a token-based API at `/v1`, and an OpenAPI spec for tool discovery. ## How an agent should use this 1. Run `nsp whoami` to check if the user is logged in. If `command not found`, install with `curl https://nanostudiopro.com/cli/nsp | node -` (or just hit the API directly with their token). 2. If 401 / not logged in: tell the user to run `nsp login` (opens browser, RFC 8628 device flow). 3. For unknown endpoints: fetch `/api/openapi` and read the spec. 4. Capability detection (does this server support feature X?): `GET /v1/meta` — no auth required. ## Auth - **Token storage:** `~/.config/nsp/credentials.json` (mode 0600). Format: `{ "access_token": "sk_sf_live_...", "server": "https://nanostudiopro.com" }`. - **Header:** `Authorization: Bearer sk_sf_live_...` - **Get the token from the CLI:** `nsp token` (prints to stdout, safe to pipe into curl). - **Manual PAT:** Settings → API Tokens at https://nanostudiopro.com/settings/api-tokens. ## CLI (`nsp`) Pure Node, no deps. Install: `curl https://nanostudiopro.com/cli/nsp | node -` (or save to `/usr/local/bin/nsp` and `chmod +x`). | Command | Purpose | |---|---| | `nsp login` | Device-flow auth (opens browser) | | `nsp logout` | Delete saved token | | `nsp whoami` | Show current user (verifies session) | | `nsp credits` | Wallet balance + token daily cap | | `nsp pricing` | Credit cost per operation | | `nsp token` | Print saved token (for piping) | | `nsp mcp` | Run the MCP server (downloads/caches on first use) | Override server: `NSP_SERVER=https://staging.example.com nsp whoami`. ## API endpoints Base: `https://nanostudiopro.com/api/v1` ### Generative - `POST /v1/generations` — create an image generation. Returns `{ task_id, ...generation }`. Supports up to **14 reference images** — either upload inline via multipart (`reference_file[]`) or pass existing asset IDs (`reference_asset_id[]`). Uploaded files are auto-saved to the user's asset library; their IDs come back as `saved_asset_ids`. Requires `project_id`. - `POST /v1/restyle` — AI-edit an existing generation (`generation_id`) or uploaded asset (`asset_id`, never both) into a NEW generation; an asset is only read, never copied: plain-text edits (`instructions`), one-click product placement (`action: "bring"` + `reference_id`), item recolor/remove/add (`items` names from detections), two-image merge, art-style transfer. `reference_id` = any asset or generation you own. - `POST /v1/expand` — outpaint to a bigger canvas / new `target_aspect_ratio` (directional `extend`, `zoom` < 1 zooms out). - `POST /v1/upscale` — re-render at a higher `resolution` (1K/2K/4K). Both take `generation_id` or `asset_id`; an asset's result goes to `project_id` (default: the asset's own project). - `POST /v1/cutouts` — subject cutout: transparent PNG + matte + clean background plate. One image per call. - `GET /v1/sheets/options` — the menus a sheet is made from, free: kinds, keyable grounds, art styles (photographic, drawn, painted), animation sequences by subject or by game type with frame counts per level (key / full / smooth), the image models and their ceilings. `?family=&type=` drills into one type's frame lists. - `POST /v1/sheets` — make ONE image of several separate elements laid out so each can be cut out (an animation cycle, a sprite sheet, an icon set, a sticker pack, props), server-side: name `kind`, `sequences` by id and/or `items`, `subject`, `art_style`, `ground`, `model`; the server plans the grid, writes the prompt (asserted count, keyable ground, no lines or labels, cells big enough to use) and records the recipe. `dry_run: true` quotes `credits_cost` and makes nothing. Never write a sheet prompt yourself. - `GET /v1/sheets/{id}/atlas` — a sheet's frame rects, registration, fps, pivot and one animation tag per sequence, as Aseprite JSON any engine imports. Free. - `POST /v1/videos` — make a video from an image you own. `model`: kling-v3 (default, 3-15s, std/pro/4k, optional audio, `end_frame_id`), kling-v3-omni (up to 6 reference stills, or 3 beside a reference clip), kling-video-o1 (Omni with a clip at Kling 3.0 prices, up to 10s, silent), kling-motion-control (a clip's movement performed by your still), veo-3.1-lite-generate-preview (4/6/8s, audio always, the cheapest sound), gemini-omni-1.2-flash (3-15s, 360p to 4K; `reference_video_id` = a clip of up to 15s to EDIT by describing the change, or up to 3 `reference_video_ids` to follow), dreamina-seedance-2-5-260628 (Seedance 2.5: 4-30s, 720p/1080p, sound always, `end_frame_id` or up to 6 reference stills, clips in `reference_video_ids` and sounds in `reference_audio_urls` or `reference_audio_ids` from `POST /v1/videos/reference-audio`). Priced per second; the 202 says `credits_cost`. `dry_run: true` quotes the exact price and submits nothing. Async: poll `GET /v1/videos/{task_id}`. Credits deduct on completion; requires purchased credits (`402 video_requires_purchase` on trial). `GET /v1/meta` lists every model with its dials, and marks any switched off for now (`available: false` + `unavailable_reason`; calling one answers `503 model_unavailable`). ### Detections (free) - `GET /v1/detections/{target_id}?type=generation|asset` — what the detection engine sees: item names, categories, textures, hex colors, bounding boxes (0-1000 normalized), scene narrative. Every generation/import is scanned automatically. Each item has an `id` (fixed per `scan_id`) and a `label` that tells repeated names apart ("person (left)"); `POST /v1/restyle` with `action: "remove"` and `items: [{ "id": 2 }]` removes only that instance. - `POST /v1/scans` — run the scan on a never-scanned image (inline, ~5-20s, free). ### Search & assets - `GET /v1/search?q=...` — full-text + detection-aware search across the user's assets. Supports `regions`, `image_size`, `colors`, date range, sort, aspect filter. - `GET /v1/assets/{id}` — asset metadata. ### Entities (characters, props, places, skins, looks) - `GET /v1/entities` / `GET /v1/entities/{id}` — the recurring cast with reference sets, sheets, looks, links (each with its `id`), facets. - `POST /v1/entities` — find-or-create by `kind` and `name` (200 found / 201 made); optional `refs` (`[{ kind: "generation"|"asset", id, role }]`, replaced) and `traits` (e.g. `{ bio: { description } }`, merged). `PATCH /v1/entities/{id}` edits name, refs, traits. - `POST /v1/entities/{id}/style` — COSTS CREDITS (one image). `{ name, refs: [{ kind, id }] (1-4 style pictures), note?, project_id, dry_run? }`: the same subject drawn in a named art style, a new entity of the same kind named " ·