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 Tasks 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: Tasks
description: Lifecycle records for every async operation the API kicks off — generations, scans, uploads, exports. Every endpoint that does server-side work returns a `task_id` you can poll here for status (`running` → `complete`/`failed`), error messages, retries, and external-provider state (Kling video, etc.). Useful for building dashboards, audit trails, and webhook-free status polling.
paths:
/v1/tasks/stream:
get:
tags:
- Tasks
summary: Real-time task event stream (SSE)
description: 'Server-Sent Events firehose. Hold the connection open and you''ll receive a JSON event every time one of *your* tasks changes state — queued → running → complete (or failed/canceled). Each event has the same shape as `GET /v1/tasks/{id}` so you can reuse the same parser. Lets you replace polling with `for await (const event of stream)` patterns.
**Heartbeats** every 25s prevent reverse proxies from killing idle connections. Browser EventSource and most SSE libraries auto-reconnect on drop; on reconnect, fetch `GET /v1/tasks?completedAfter=` to backfill anything missed during the disconnect window.
**Event shape:**
```
data: { "type": "task.update", "task": { ...Task } }
data: { "type": "heartbeat" }
```'
responses:
'200':
description: Event stream.
content:
text/event-stream:
schema:
type: string
'401':
description: Missing or invalid token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: unauthorized
message: Missing or invalid token
'429':
description: Rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded
operationId: getV1TasksStream
x-operation-id-source: derived
/v1/tasks:
get:
tags:
- Tasks
summary: List your async tasks
description: 'Returns the authenticated user''s tasks — uploads, scans, exports, and generations of every kind — with their lifecycle status. Useful for polling job state from external clients.
Every operation that creates server-side work has a Task row. POST endpoints like `/v1/generations` return a `task_id` you can pass to `/v1/tasks/{id}` for status updates.'
parameters:
- name: status
in: query
schema:
type: string
example: running,failed
description: Comma-separated subset of `queued | running | complete | failed | canceled`.
- name: action
in: query
schema:
type: string
enum:
- upload
- scan
- export
- generate
- name: kind
in: query
schema:
type: string
description: Exact `kind` match (e.g. `generate.video`).
- name: parent_task_id
in: query
schema:
type: string
description: Only return children of this task.
- name: since
in: query
schema:
type: string
format: date-time
- name: completed_after
in: query
schema:
type: string
format: date-time
- name: limit
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 50
responses:
'200':
description: List of tasks (most recently started first).
content:
application/json:
schema:
type: object
properties:
tasks:
type: array
items:
$ref: '#/components/schemas/Task'
'401':
description: Missing or invalid token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: unauthorized
message: Missing or invalid token
'429':
description: Rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded
operationId: getV1Tasks
x-operation-id-source: derived
/v1/tasks/{id}/contact-sheet:
get:
tags:
- Tasks
summary: A clip's contact sheet (free)
description: 'A finished task''s clip (a generated video, a storyboard take, an import) as one JPEG grid of `frames` frames, evenly through it, each with its number and second in its corner: to see a clip''s direction, framing and where to trim without watching it.'
parameters:
- name: id
in: path
required: true
schema:
type: string
- name: frames
in: query
schema:
type: integer
minimum: 4
maximum: 24
default: 12
responses:
'200':
description: The sheet
content:
application/json:
schema:
type: object
properties:
task_id:
type: string
duration_s:
type: number
columns:
type: integer
times:
type: array
items:
type: number
description: Each frame's second, in grid order
mime:
type: string
example: image/jpeg
data:
type: string
description: The JPEG, base64
'404':
description: No such task
'409':
description: The task has no finished clip
operationId: getV1TasksByIdContactSheet
x-operation-id-source: derived
/v1/tasks/{id}:
get:
tags:
- Tasks
summary: Get a single task
description: 'Fetch one task by id. Useful for polling the status of a job kicked off via `POST /v1/generations` or any other endpoint that returns a `task_id`, of any kind. Once complete it also carries its result, signed: `video_url` and `poster_url` for a clip (a generated video, a storyboard take, an import), `image_url` for a picture, `file_url` for an asset.'
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Task details.
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
'401':
description: Missing or invalid token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: unauthorized
message: Missing or invalid token
'404':
description: Task not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: not_found
message: Task not found
'429':
description: Rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded
operationId: getV1TasksById
x-operation-id-source: derived
/v1/tasks/{id}/cancel:
post:
tags:
- Tasks
summary: Cancel a running task
description: 'Marks a `queued` or `running` task as `canceled`. Note: synchronous tasks (everything except video) typically complete in seconds, so the cancel window is narrow. For async provider tasks (video) the cancel propagates to our records but does not abort the external provider''s job — you may still be billed by them.'
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Task canceled.
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
'400':
description: Task is already in a terminal state
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: validation_error
message: Task is already in a terminal state
'401':
description: Missing or invalid token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: unauthorized
message: Missing or invalid token
'404':
description: Task not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: not_found
message: Task not found
'429':
description: Rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded
operationId: postV1TasksByIdCancel
x-operation-id-source: derived
/v1/tasks/{id}/retry:
post:
tags:
- Tasks
summary: Retry a failed task
description: Flips a `failed` task back to `running` in place — the row's `retries` counter increments, `error` clears, and a new attempt begins. Currently only the row state changes; the underlying executor replay is being added in a follow-up release. For now, treat this as a way to bookkeeping-mark an attempt for a manual re-trigger.
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Task retried.
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
'400':
description: Task is not in failed status, or max retries reached
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: validation_error
message: Task is not in failed status, or max retries reached
'401':
description: Missing or invalid token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: unauthorized
message: Missing or invalid token
'404':
description: Task not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: not_found
message: Task not found
'429':
description: Rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded
operationId: postV1TasksByIdRetry
x-operation-id-source: derived
components:
schemas:
Error:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
properties:
code:
type: string
example: validation_error
message:
type: string
example: '`prompt` is required'
needed:
type: integer
nullable: true
description: '402 only: what the operation costs in credits, when known.'
balance:
type: integer
nullable: true
description: '402 only: what the account has (for `token_cap_exceeded`, what the token may still spend today), when known.'
purchase_url:
type: string
format: uri
description: '402 only: where the person adds credits. Every 402 (`insufficient_credits`, `token_cap_exceeded`, `video_requires_purchase`, `audio_requires_purchase`, `storage_limit_exceeded`, `trial_required`) carries the same fields, so one handler can show the notice. `trial_required` answers an upload from an account that has not started its free trial: nothing was stored, and the upload goes through once the trial is on.'
Task:
type: object
description: Lifecycle row for an async operation (generations, uploads, scans, exports). Returned by `/v1/tasks` so external clients can poll their jobs the same way the in-app UI does.
properties:
id:
type: string
action:
type: string
enum:
- upload
- scan
- export
- generate
description: High-level grouping of the operation.
kind:
type: string
description: Specific operation — e.g. `generate.quick`, `generate.restyle`, `generate.video`, `generate.angles`, `upload`, `scan`, `export`.
status:
type: string
enum:
- queued
- running
- complete
- failed
- canceled
progress:
type: integer
minimum: 0
maximum: 100
description: Best-effort 0-100; many endpoints leave it at 0.
error:
type: string
nullable: true
description: User-facing error message if `status=failed`.
label:
type: string
nullable: true
example: Generate · gold transformation
origin:
type: string
nullable: true
description: Where the task was triggered from. `API` for external callers, plus values like `Prompter`, `Card menu`, `Pose editor`.
display_meta:
type: object
nullable: true
additionalProperties: true
description: Free-form metadata (aspect ratio, project id, thumbnail path) used by the UI placeholder. Safe for external clients to display verbatim.
intent:
type: object
nullable: true
additionalProperties: true
description: Endpoint + body the task originated from. Used internally for retries.
retries:
type: integer
description: How many retry attempts have been made.
max_retries:
type: integer
provider:
type: object
nullable: true
description: External-system tracking for async providers (Kling video, future Runway/Pika/etc.). `null` for synchronous providers like Gemini.
properties:
key:
type: string
example: kling
task_id:
type: string
nullable: true
description: External system's job id.
status:
type: string
nullable: true
description: Provider-specific status string.
updated_at:
type: string
format: date-time
nullable: true
generation_id:
type: string
nullable: true
description: FK to the resulting Generation, if applicable.
asset_id:
type: string
nullable: true
description: FK to the resulting Asset, if applicable.
scan_result_id:
type: string
nullable: true
parent_task_id:
type: string
nullable: true
description: For batched operations — points to the parent Task.
started_at:
type: string
format: date-time
completed_at:
type: string
format: date-time
nullable: true
created_at:
type: string
format: date-time
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.'