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 Search 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: Search
description: Full-text + detection-aware search across everything you've uploaded or generated. Backed by a Postgres GIN index over scan results — finds matches by name, prompt, detected items (clothing, poses, colors, textures), and falls back to fuzzy trigram matching for typos. Set `include_regions=true` to get bounding boxes you can overlay on the image.
paths:
/v1/search:
get:
tags:
- Search
summary: Search your assets and generations
description: 'Full-text + detection-aware search. The query (`q`) matches against image names, prompts, AI-generated narratives, and every detected item — clothing, poses, colors, textures, actions. Returns image-level matches scored by relevance. Set `include_regions=true` to get the matching bounding boxes overlaid by your client; coords are normalized 0..1 so they scale to any render size. Stale-while-revalidate caching: rapid repeat queries are instant. Read scope.
Four modes, one response shape: `mode=text` (default) is the full-text engine above. `mode=color` ranks your whole library by perceptual (OKLab) proximity to a hex color — add `q` to color-reorder a text search instead. `mode=similar` ranks by likeness to one anchor image (`similar_to` + `similar_type`), with `similar_mode` picking the flavor: `all` (blended, default), `items` (same detected stuff), `scene` (same lighting/mood/setting vocabulary), `story` (same narrative). `mode=browse` asks nothing and returns the catalogue newest-first. Color, similar, and browse results carry `score: 0` (they are ranked browses, not text relevance).
Text mode also reaches INSIDE indexed videos: an instant of footage that matches the words arrives as an ordinary item flagged `is_video`, whose `video_moment` names the exact `time_ms` — one clip is one card (its best-matching moment), ranked in by relevance alongside the photos. Filter to clips alone with `gen_type=video`.
The one endpoint **publishable keys** (`pk_sf_live_`) can call — embeddable in public pages and callable cross-origin from browsers. Every response (errors included) echoes the request''s `Origin` back in `Access-Control-Allow-Origin` (`*` when absent) and sends `Vary: Origin`; preflights are answered by the `OPTIONS` operation below. A key''s `search_scope` narrows results silently — see the notes on `type`, `project_id`, `image_size`, and `include_regions`. A key with an `origins` allowlist answers `403 forbidden` to browser requests from any other origin.'
parameters:
- name: mode
in: query
description: Search flavor. `text` (default) requires `q`. `color` requires `color` (`q` optional — with it, the text results are re-ranked by color proximity). `similar` requires `similar_to` + `similar_type` and ignores `q`. `browse` needs nothing and returns the catalogue newest-first — what an embedded widget shows before a visitor has typed.
schema:
type: string
enum:
- text
- color
- similar
- browse
default: text
- name: q
in: query
description: Search query — required for `mode=text` (the default), optional for `mode=color`, ignored for `mode=similar`. Multi-word queries are AND'd; the last word gets prefix-matching while you're still typing (e.g. `red dr` matches `red dress`). Trailing whitespace anchors the last word as exact.
example: red dress beach
schema:
type: string
minLength: 1
- name: color
in: query
description: Target color for `mode=color`, as a 6-digit hex (`#` optional). Converted server-side to OKLab — the same perceptual space the in-app picker uses — so `#7a1f1f` returns your wine-red photos, ranked by how much of each image IS that color.
example: '#7a1f1f'
schema:
type: string
pattern: ^#?[0-9a-fA-F]{6}$
- name: similar_to
in: query
description: Anchor image ID for `mode=similar` (an asset or generation you own).
schema:
type: string
- name: similar_type
in: query
description: What `similar_to` refers to. Required with `mode=similar`.
schema:
type: string
enum:
- asset
- generation
- name: similar_mode
in: query
description: Similarity flavor for `mode=similar`. `all` blends the three signals; `items` = same detected items; `scene` = same lighting/mood/setting; `story` = same narrative situation.
schema:
type: string
enum:
- all
- items
- scene
- story
default: all
- name: limit
in: query
description: Page size, 1–100.
schema:
type: integer
minimum: 1
maximum: 100
default: 40
- name: offset
in: query
description: Pagination offset. Use `next_offset` from the previous response.
schema:
type: integer
minimum: 0
default: 0
- name: type
in: query
description: 'Restrict to one source. Default returns both. Publishable keys: narrowed by the key''s `search_scope.types` — a type outside the scope returns an empty 200 page (`next_offset: null`), never an error.'
schema:
type: string
enum:
- asset
- generation
- name: project_id
in: query
description: 'Comma-separated project IDs to filter by. Publishable keys: intersected with the key''s `search_scope.projects` — requesting only out-of-scope projects returns an empty 200 page (`next_offset: null`), never an error.'
schema:
type: string
- name: gen_type
in: query
description: Narrow to one kind of generation — `video` returns only clips, `cutout` only transparent subjects, and so on. Honored by `text` and `browse` (and `color` with `q`); a 400 with `similar` or a pure color browse, which cannot filter by kind.
schema:
type: string
enum:
- image
- video
- cutout
- collage
- uploaded
- name: style
in: query
description: Filter by detected image style.
schema:
type: string
enum:
- photograph
- 3d-render
- illustration
- name: has_pose
in: query
description: Only return images with detected skeletal pose data.
schema:
type: boolean
- name: has_colors
in: query
description: Only return images with extracted color swatches.
schema:
type: boolean
- name: colors
in: query
description: Filter by detected color. Comma-separated list, OR'd together. Accepts hex (`#7a1f1f`) or color names (`red,navy`). Hex values are resolved to the closest named color in our palette before matching, so `colors=#aa0000` and `colors=red` typically return the same set.
example: red,blue
schema:
type: string
- name: scanned_after
in: query
description: Only return results scanned at or after this ISO 8601 timestamp.
example: '2026-04-01T00:00:00Z'
schema:
type: string
format: date-time
- name: scanned_before
in: query
description: Only return results scanned at or before this ISO 8601 timestamp.
example: '2026-04-26T23:59:59Z'
schema:
type: string
format: date-time
- name: sort
in: query
description: Sort order. `relevance` (default) ranks by how well each result matches `q`. `date_desc` and `date_asc` order chronologically by scan time — useful for time-based browsing.
schema:
type: string
enum:
- relevance
- date_desc
- date_asc
default: relevance
- name: aspect
in: query
description: 'Filter by frame shape. Accepts a comma-separated list, OR''d together. Coarse words: `portrait` (< 0.95), `landscape` (> 1.05), `square` (0.95–1.05). Exact ratios: `1:1`, `3:2`, `2:3`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9` — each matches photos whose measured ratio is NEAREST that bucket, so every photo belongs to exactly one. Useful for picking source images that fit a target slot (social post, product card). Applies to `text` and `color` modes; ignored by `similar`.'
schema:
type: string
example: 16:9,3:2
- name: include_regions
in: query
description: When true, every result includes a `regions` array with the detected bounding boxes (label, category, texture, colors, normalized bbox). Heavier payload — leave off for typeahead/grid use cases. `color` and `similar` mode results don't carry detection payloads, so their items omit `regions` regardless. Publishable keys only get regions when the key's `search_scope.include_regions` is true — the flag is silently ignored otherwise.
schema:
type: boolean
default: false
- name: image_size
in: query
description: 'Resolution for `image_url`. Variants are pre-rendered at upload time, generated on-demand for legacy images on first request. Default `preview` is appropriate for most grid/card layouts. Use `original` only when you need the raw source (zoom, full-screen, download). Publishable keys with a `search_scope.max_image_size` cap are silently served the capped variant whenever the request — the `preview` default included — exceeds it: still a 200, just smaller images. Unknown values are a 400 either way.'
schema:
type: string
enum:
- xs
- thumb
- preview
- large
- original
default: preview
description: xs=100px · thumb=200px · preview=600px · large=1200px · original=raw upload (full-res)
- name: embed_key
in: query
description: 'Ask for `embed_url` on every image result: a link to place on a page, served from the edge under a publishable key''s domain rules (its allowed sites, and whether a link opened directly works). A search made WITH a publishable key gets them automatically. A server searching with its secret token names one of its own publishable keys here; any other key is ignored. The link uses the `image_size` asked for (xs is served as thumb).'
schema:
type: string
responses:
'200':
description: Paginated search results.
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
type: object
properties:
id:
type: string
description: Asset or generation ID.
type:
type: string
enum:
- asset
- generation
name:
type: string
nullable: true
image_url:
type: string
nullable: true
description: Time-limited signed URL (HMAC). Expiry snaps to a ~6-hour signing window, so URLs stay byte-stable — and browser-cacheable — within a window. Re-issue by re-fetching the search.
permanent_url:
type: string
nullable: true
description: 'A link that never expires (`/api/v1/media/{type}/{id}?sig=…`): it redirects to a fresh signed file each time, takes `&size=` like `image_url`, and stops working when the image is deleted. Use it wherever the link is stored, such as a quote or a page. Absent on video moment cards.'
image_width:
type: integer
nullable: true
image_height:
type: integer
nullable: true
aspect_ratio:
type: string
nullable: true
example: '2:3'
category:
type: string
nullable: true
description: Asset category (model, pose, background, etc.). Null for generations.
project_id:
type: string
nullable: true
score:
type: number
description: Text relevance, 0..1. Always 0 in `color` and `similar` modes (ranked browses — order carries the ranking).
scanned_at:
type: string
format: date-time
narrative:
type: string
nullable: true
description: AI-generated description of the image; present when available. Publishable keys only get it when the key's `search_scope.include_narrative` is true — omitted otherwise.
gen_type:
type: string
enum:
- image
- video
- cutout
- collage
- uploaded
description: What kind of generation this is. Present on generation hits only — `category` is null for generations, so this is the kind signal.
is_video:
type: boolean
description: Present (true) only on video hits — a clip's poster row or a matched moment. On a moment, `image_url` is the matched frame and `video_moment` says where in the clip it lives.
video_moment:
type: object
description: 'Present only on video hits from `text` mode: the exact instant inside an indexed clip that matched the query. First-page only, ranked in by relevance alongside photos; one clip appears as one item (its best-matching moment).'
properties:
moment_id:
type: string
time_ms:
type: integer
description: Milliseconds from the start of the clip.
moments_in_video:
type: integer
description: How many moments in this clip matched the query.
duration_sec:
type: number
nullable: true
shot_size:
type: string
nullable: true
example: medium
camera_motion:
type: string
nullable: true
example: pan-left
regions:
type: array
description: Present only when `include_regions=true`.
items:
type: object
properties:
label:
type: string
example: dress
category:
type: string
nullable: true
example: clothing
texture:
type: string
nullable: true
example: silk
colors:
type: array
items:
type: string
example: '#7a1f1f'
description: Hex strings, dominant first.
bbox:
type: object
description: Normalized 0..1 image-space coordinates. Multiply by your render width/height.
properties:
x:
type: number
y:
type: number
w:
type: number
h:
type: number
total:
type: integer
description: Total matches across all pages.
next_offset:
type: integer
nullable: true
description: Pass to the next request as `offset`. `null` when there are no further pages.
did_you_mean:
type: array
items:
type: string
description: Up to 3 closest names (trigram similarity). Present whenever suggestions exist.
videos_total:
type: integer
description: 'Present when the video branch matched: how many video moments matched across the library.'
videos_shown:
type: integer
description: 'Present when the video branch matched: how many clip cards joined this page (max 4, first page only). `next_offset` counts photo rows alone.'
'400':
description: Missing or invalid parameter (`q`, `mode`, `color`, `similar_to`, ...)
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: validation_error
message: Missing or invalid parameter (`q`, `mode`, `color`, `similar_to`, ...)
'401':
description: Missing or invalid token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: unauthorized
message: Missing or invalid token
'403':
description: This key is not allowed from this origin.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: forbidden
message: This key is not allowed from this origin.
'429':
description: Rate limit exceeded
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded
operationId: getV1Search
x-operation-id-source: derived
options:
tags:
- Search
summary: CORS preflight
description: 'Browser preflight for cross-origin calls (publishable keys embedded on other sites). Always `204` with permissive headers — `Access-Control-Allow-Origin: *`, methods `GET, OPTIONS`, headers `Authorization, Content-Type`. A preflight carries no Authorization header, so it can''t be token-aware; the real enforcement (origin allowlist, scope narrowing, rate limits) happens on the GET.'
security: []
responses:
'204':
description: Preflight accepted.
operationId: optionsV1Search
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.'
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.'