# ShineStudio API v1 Reference

Base URL: `https://app.shinestudio.ai`

This is the public API. Scripts, scheduled jobs, your own apps and AI assistants can use it to make
ad images and ad videos with ShineStudio. Everything made through the API also appears in your
ShineStudio gallery, the same as work made in the browser.

Want to use ShineStudio from Claude, ChatGPT, Codex or another AI app instead of writing code? Use
the AI connector (MCP). Setup guide: https://app.shinestudio.ai/MCP.md

---

## Authentication

Every `/v1/*` endpoint except `/v1/health` needs an API key.

- **Get a key:** sign in at https://app.shinestudio.ai, click the gear icon (Settings) at the top
  right, scroll to **API keys**, type a name and press **Generate**. The full key is shown **once**,
  so copy it then. After that only a masked preview is shown. You can have up to 10 keys.
- **Format:** `adw_live_` followed by 32 letters, digits, `-` or `_`.
- **Header:** `Authorization: Bearer adw_live_YOUR_KEY_HERE`
- **Who pays:** every key belongs to the account that made it. Calls spend that account's credits,
  and jobs, history and library data are private to that account.
- **Account approval:** an account must be approved for API access. If every call returns 403 with
  "This account needs admin approval before using the API.", contact support. Disabled accounts
  cannot use their keys.
- **Revoke** a key in Settings, API keys. Jobs already running finish; new calls fail within about
  30 seconds.

Keep keys private. Anyone holding a key can spend your credits.

### If you get a 403 with `error code: 1010`

That is the edge network refusing the request's User-Agent, not a key problem. Some default HTTP
clients (notably Python's `urllib`) send a User-Agent that gets blocked. Set a normal one and the
same request works. `curl` and most SDKs are fine.

---

## Credits and billing

- **1 credit = 1 cent of value.** API and connector calls spend the key owner's credits, from the
  same balance the app uses.
- **Monthly plans:** $19 a month = 2,000 credits, $29 = 4,000, $99 = 14,000. Monthly credits are used
  first and refresh each month. Credits from packs never expire.
- **Accounts created on or after November 20, 2026** need a monthly plan before they can buy packs.
- **Buying credits** happens in the app, not through the API: click the credit balance at the top
  right to open the Credit Center.
- **The server sets every price** from the model, resolution, quality (images), length, shape
  (Seedance), mode and reference pictures (HeyGen). Anything you send cannot lower it. The price
  lists below are the default list prices. The live price list is in the app, and a 402 reply
  always states the real cost.
- **Out of credits:** a paid call returns `402` before any work starts.
- **Refunds:** a generation that fails is refunded once, automatically. A synchronous call that
  returns an error is refunded too. If the outcome is unknown (for example a lost connection after
  the work was accepted), the credits are held and checked by support rather than refunded or
  charged blindly.
- **Text and vision calls** (scripts, product scans, beats, analysis, raw text) cost a tiny amount
  each: a tenth of a credit at the default rate (a script with a story of 30 or more characters
  counts as two calls).
- **Free:** status checks, history, the library, `/v1/product/extract`, `/v1/upload` and
  `/v1/video/frame`.

### Common error responses

Errors come back as JSON with an `error` field (and sometimes `details`).

| Code | Means |
|---|---|
| 400 | The request is invalid. `details` lists what to fix, or `error` says it in plain words. |
| 401 | The key is missing, invalid or revoked. |
| 402 | Not enough credits. Body: `{"error":"Not enough ShineCredits (this ... costs 20). ...","code":"INSUFFICIENT_CREDITS","cost":20}` |
| 403 | The account needs approval for API access (or see the 1010 note above). |
| 404 | Unknown job ID, or it belongs to another account. |
| 408 / 413 | The request body was too slow or too large. |
| 429 | Too many requests: wait a minute and try again. |
| 503 | A part of the service is briefly unavailable. Try again shortly. |
| 500 / 502 | The generation service returned an error. |

---

## Connect an AI assistant (MCP)

ShineStudio is also an MCP server, so Claude (Claude Code, the Claude desktop app, Claude Cowork,
claude.ai), ChatGPT, Codex, Cursor and other MCP apps can make images and videos by calling it as
tools. The AI reads a built-in guide when it connects (every model, its limits, defaults, prices,
reference tags, library codes and link expiry), so you only have to say what you want.

| | |
|---|---|
| Address | `https://app.shinestudio.ai/mcp` with the header `Authorization: Bearer adw_live_YOUR_KEY_HERE` |
| Private link | `https://app.shinestudio.ai/mcp/adw_live_YOUR_KEY_HERE`, for apps with no place for a header (Claude custom connectors, ChatGPT) |
| Transport | Streamable HTTP, stateless, JSON-RPC 2.0. No OAuth. |
| Discovery | `GET https://app.shinestudio.ai/mcp` (no key) describes the service |

**The private link works like the key.** Anyone holding it can spend your credits. It is shown with
**Copy AI connector link** right after you generate a key. Keep it private and revoke the key if it
leaks.

**Step by step setup** for every app: https://app.shinestudio.ai/MCP.md. The same text, ready to
paste into an AI agent, is one click away in Settings, API keys, **Copy setup instructions for any
AI agent**.

**How long calls take.** No tool takes longer than about 50 seconds, so default client timeouts are
fine. Image tools wait up to about 35 seconds: a 1k image often comes back finished, while 2k and 4k
images usually come back as a `jobId` to check with `get_job` about every 15 seconds. A video always
comes back as a `jobId` to check about once a minute.

### The 25 tools

| Tool | What it does | Cost |
|---|---|---|
| `get_guide` | The full guide: models, limits, defaults, prices, tags, codes | Free |
| `health` | Check ShineStudio is online | Free |
| `generate_ad_image` | Make one image | Credits |
| `generate_ad_batch` | Make up to 20 images, one per prompt, same settings (5 at a time) | Credits each |
| `generate_ad_video` | Start one video, returns a `jobId` | Credits |
| `get_job` | Check an image or video job | Free |
| `extract_video_frame` | Cut the first, last or any frame from a finished video | Free |
| `list_library_assets` | Every Product Library picture with its code, like `B5` | Free |
| `list_generations` | Past images and videos, newest first, including ones made in the app | Free |
| `upscale_image` | Upscale an image to 2K, 4K or 8K | Credits |
| `remove_background` | Transparent PNG of an image | Credits |
| `upload_to_public_url` | Turn image bytes or a link into a temporary public link | Free |
| `generate_ad_script` | Write a Seedance shot list | Text call |
| `scan_product_images` | Product notes and a buyer persona from photos | Text call |
| `expand_directive_to_beats` | Turn a story idea into 4 to 6 timed beats | Text call |
| `extract_product_from_url` | Pull images and title from a product page | Free |
| `analyze_image_style` | A reusable style description from a picture | Text call |
| `analyze_video_clip` | Vibe, scene structure, audio and look of a video | Text call |
| `gemini_chat` | Send any prompt to the text and vision model | Text call |
| `list_library` | Folders, prompt templates, vibes, hooks and settings | Free |
| `create_folder`, `update_folder`, `delete_folder` | Manage Product Library folders | Free |
| `save_prompt_template`, `delete_prompt_template` | Manage saved prompts | Free |

### Checking the connector by hand

```bash
KEY="adw_live_YOUR_KEY_HERE"

# Initialize
curl -sf -X POST https://app.shinestudio.ai/mcp \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0"}}}'

# List the tools
curl -sf -X POST https://app.shinestudio.ai/mcp \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
```

---

## Quick example

```bash
KEY="adw_live_YOUR_KEY_HERE"

# Make one image
curl -sf -X POST https://app.shinestudio.ai/v1/image/generate \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{"prompt":"red apple on white","ratio":"1:1","model":"gpt-image-2.5-sunburst","mode":"text-to-image","resolution":"2k"}'
# → 202 { "jobId": "uuid", "status": "running" }

# Check the job until status is success
curl -sf -H "Authorization: Bearer $KEY" https://app.shinestudio.ai/v1/jobs/JOB_ID
```

---

## Endpoint list

### Public
- `GET /v1/health`: is the service up (no key).

### Images
- `POST /v1/image/generate`: make an image (async, returns a `jobId`).
- `POST /v1/upscale`: upscale to 2K, 4K or 8K (sync).
- `POST /v1/bg-remove`: remove the background (sync).
- `POST /v1/image/analyze`: a reusable style description from a picture (streamed).

### Videos
- `POST /v1/video/generate`: make a video (async, returns a `jobId`).
- `POST /v1/video/frame`: cut one still out of a finished video. Free.
- `POST /v1/script/generate`: write a Seedance ad script.
- `POST /v1/directive/expand`: turn a story idea into 4 to 6 concrete beats.
- `POST /v1/video/analyze`: vibe, scene structure, audio and look of a video (streamed).

### Products
- `POST /v1/product/scan`: product notes and a buyer persona from photos.
- `POST /v1/product/extract`: images and title from a product page URL. Free.

### Other
- `POST /v1/upload`: turn image bytes or a link into a temporary public link. Free.
- `POST /v1/gemini/chat`: a raw text and vision AI call for anything else.

### Jobs and history
- `GET /v1/jobs/:id`: check any image or video job.
- `GET /v1/generations`: your finished images and videos, newest first.

### Library
- `GET /v1/library/assets`: every Product Library picture with its code.
- `GET /v1/library`: folders, prompts, vibes and hook and setting customs, in one call.
- `GET|POST /v1/library/folders`, `GET|PATCH|DELETE /v1/library/folders/:id`
- `GET|POST /v1/library/prompts`, `DELETE /v1/library/prompts/:id`
- `GET /v1/library/vibes`, `PUT|DELETE /v1/library/vibes/:vibeId`
- `GET|PUT /v1/library/hook-setting`

---

## Size limits

- **Request body:** up to 56 MB of JSON. A file sent as a data URL can be up to 40 MB.
- **Lists:** `sources`, `imageUrls`, `videoUrls`, `audioUrls`, `images`, `references` and `parts`
  take at most 30 items each (and each model has its own lower limit, listed below).
- **Prompts:** images up to 32,000 characters, Seedance up to 10,000, HeyGen up to 8,000.
- **Text calls:** `/v1/script/generate` takes up to 100,000 characters in total.
  `/v1/gemini/chat` takes up to 100,000 characters of text and 10 pictures, and returns at most
  16,384 tokens.
- **Rate limits:** per account, 100 generations and 60 text calls a minute (app and API combined).
  Checking job status does not count.

---

## Endpoint details

### `GET /v1/health`

No key. Returns `{ ok, service, version, uptime, ... }` with status 200 when everything is ready,
or 503 when part of the service is down.

---

### `POST /v1/image/generate` (async)

| Field | Type | Notes |
|---|---|---|
| `prompt` | string | Required. Sent exactly as written, nothing added. Up to 32,000 characters. |
| `ratio` | string | Required. `1:1` `4:5` `3:4` `9:16` `4:3` `16:9` `auto`. `4:5` is delivered as `3:4`. Anything else becomes `1:1`. |
| `model` | string | Required. `gpt-image-2.5-sunburst` (normal) or `gpt-image-2.5-flare` (faster, same price). `gpt-image-2` is retired but still accepted for older integrations. `nano-banana` was removed. |
| `mode` | string | `text-to-image` or `image-to-image`. **If left out it is `image-to-image`**, which needs `sources`, so send `text-to-image` when you have no pictures. |
| `sources` | string[] | 1 to 16 reference pictures for `image-to-image`: public https links or data URLs. |
| `resolution` | string | `1k` / `2k` / `4k`. Default `2k`. |
| `quality` | string | `low` / `medium` / `high`. Default `medium`. Resolution and quality together set the price. |

Returns `202 { jobId, status }`. Check `/v1/jobs/:id` until `status` is `success`, then use
`result.imageUrl`.

Rough times: 1k about 30 seconds, 2k a minute or more, 4k two minutes or more.

**Image prices** (default list price, credits per image):

| Model | `1k` | `2k` | `4k` |
|---|---|---|---|
| GPT Image 2.5 (Sunburst or Flare), `low` | 5 | 10 | 15 |
| GPT Image 2.5 (Sunburst or Flare), `medium` | 12 | 20 | 35 |
| GPT Image 2.5 (Sunburst or Flare), `high` | 45 | 75 | 135 |

---

### `POST /v1/upscale` (sync, usually 10 to 40 seconds)

| Field | Type | Notes |
|---|---|---|
| `imageUrl` | string | Required. A public http(s) link to the image. |
| `targetResolution` | string | `2k` / `4k` / `8k`. Default `4k`. |

The picture is enlarged 2x, 4x or 8x, the most that fits the size you ask for (2k = up to
2048x2048 pixels in total, 4k = 4096x4096, 8k = 8192x8192). A picture too big to double inside
that size is refused with a 400 that names the size to ask for (you are not charged). The file
type follows the input (JPG stays JPG, WEBP stays WEBP, anything else becomes PNG), and a
transparent picture keeps its transparency.

Returns `{ "url": "...", "targetResolution": "4k", "width": 1728, "height": 3072 }`. 3.8 / 10 / 30
credits for 2k / 4k / 8k at the default rate.

---

### `POST /v1/bg-remove` (sync, usually under 10 seconds)

Body: `{ "imageUrl": "https://..." }` (a public http(s) link). Returns `{ "url": "..." }`, a
transparent picture. 2.5 credits at the default rate. Pictures larger than 4096 pixels on a side
are shrunk to fit first.

Tip: for a large transparent picture, remove the background first, then upscale (the upscale
keeps the transparency).

---

### `POST /v1/video/generate` (async)

| Field | Type | Notes |
|---|---|---|
| `prompt` | string | Required. For Seedance, a full script works best (see `/v1/script/generate`). Refer to pictures as `@image1`, `@image2` and Seedance reference videos as `@video1`. |
| `model` | string | Default `seedance-2-0-mini`. See the model table below. `veo3` and `seedance-1-5-pro` were removed and are refused before any charge. |
| `duration` | number | Seconds. Out of range values are moved to the nearest allowed length, never refused. There is no automatic length: `-1` becomes the shortest. |
| `resolution` | string | See the model table. Default `480p` (HeyGen `768p`). A size the model does not make falls back to its default. |
| `aspectRatio` | string | Default `9:16` for Seedance and HeyGen. See "Shapes" below. |
| `references` | array | Pictures and videos in tag order: library codes (`"B5"`), https links, or `{ "url", "type": "image"\|"video"\|"audio", "description"? }` objects. See below. |
| `imageUrls` | string[] | Instead of `references`: picture links (https or data URLs) in tag order. |
| `videoUrls` | string[] | Seedance only: reference video links, `@video1` onward. |
| `audioUrls` | string[] | HeyGen `reference` mode only: one voice clip to lip-sync to. Refused for Seedance. |
| `sound` | boolean | Seedance only. Default `true`. |
| `heygenMode` | string | HeyGen only. `text` (no pictures), `first-frame` (exactly 1 picture, which opens the video) or `reference` (1 to 3 pictures, plus at most 1 voice clip, for lip-sync). Left out: no pictures is `text`, one picture is `first-frame`, two or more pictures or a voice clip is `reference`. Send `reference` yourself when one picture is a product or character reference rather than the opening shot. |
| `seed` | number | A whole number from 0 to 2,147,483,647. The same seed and settings repeat a take. Made for HeyGen; Seedance accepts it too. |
| `grokStyle` | string | `grok-video` only: `fun` / `normal` / `spicy`. Default `normal`. |
| `grokImageTaskId`, `grokImageIndex` | string, number | `grok-video` only, advanced: continue from a finished Grok image task (index 0 to 5) instead of sending `imageUrls`. |

The mode is picked from what you attach, so there is no `mode` field to set (it is ignored).

**Models**

| `model` | Length | Sizes | Pictures | Notes |
|---|---|---|---|---|
| `seedance-2-0-mini` | 4 to 15 s | `480p`, `720p` | up to 9 | The default and the cheapest Seedance model. Up to 3 reference videos. |
| `seedance-2-0-fast` | 4 to 15 s | `480p`, `720p` | up to 9 | Quicker than Mini. Up to 3 reference videos. |
| `seedance-2-0` | 4 to 15 s | `480p`, `720p`, `1080p`, `4k` | up to 9 | Best quality. Up to 3 reference videos. |
| `seedance-2-5` | 4 to 30 s | `480p`, `720p` | up to 9 | Longest. Up to 3 reference videos. |
| `grok-video` | 6 to 30 s | `480p`, `720p`, `1080p` | up to 7 (1 at `1080p`) | Text or pictures. About a minute. |
| `grok-imagine-video-1-5` | 1 to 15 s | `480p`, `720p`, `1080p` | 1 to 7 | Needs at least one picture. |
| `heygen-video-1` | 5 to 15 s | `480p`, `768p`, `2k` | up to 3 | Makes its own sound (speech, ambience). Usually under a minute. |

**Seedance rules.** Pictures past the 9th are ignored. A 4th reference video, or any voice clip,
is refused before anything is charged. Each reference video must be 2 to 15 seconds long, and all
reference videos together at most 15 seconds. Every picture and video must be reachable on the
public internet.

**Shapes**

- Seedance 2.0, Fast and Mini: `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`, `9:21`.
- Seedance 2.5: the same without `9:21`.
- Any other shape (`auto` included) becomes `9:16`. `21:9` and `9:21` cost more per second.
- HeyGen: `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16` (anything else becomes `9:16`). In
  `first-frame` mode the video takes the picture's shape.
- Grok: `1:1`, `3:2`, `2:3`, `16:9`, `9:16`. Send `aspectRatio` for Grok: left out, it is `3:2` with
  no picture and `16:9` with pictures.

#### How to send reference pictures (and Seedance reference videos)

Put them in `references`, in the order you want them tagged. Three ways, and they can be mixed:

1. A library code: `"B5"` (`GET /v1/library/assets` lists every code).
2. A plain link: `"https://example.com/ring.png"`. A plain link is always treated as a picture.
3. An object: `{ "url": "https://example.com/walk.mp4", "type": "video", "description": "the walk to copy" }`. `type` is `image` (the default), `video` or `audio`.

Order sets the tag: the first picture is `@image1`, the second `@image2`, the first video `@video1`
(a HeyGen voice clip is `@audio1`). Write the prompt against those tags. An unknown library code
fails the request instead of being skipped, because skipping it would shift every later tag.

**No need to upload anything first.** Any public https link works, and so does a data URL (as an
object's `url`, or in `imageUrls`). ShineStudio hosts each one itself before the job starts. For
Grok, send `imageUrls` or library codes (plain links in `references` are only used for Grok when
the list also has a library code).

```bash
curl -sf -X POST https://app.shinestudio.ai/v1/video/generate \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{
    "model": "seedance-2-0-mini",
    "duration": 5,
    "aspectRatio": "9:16",
    "references": [
      "B5",
      "https://example.com/ring.png",
      { "url": "https://example.com/walk.mp4", "type": "video", "description": "the walk to copy" }
    ],
    "prompt": "@image1 walks toward the camera the way the person in @video1 walks, then holds up @image2 and smiles."
  }' | jq -r .jobId
```

Returns `202 { jobId, status }`. Check `/v1/jobs/:id` until `status` is `success`, then use
`result.videoUrl`. Open it and check the clip really shows your pictures before making the next
one. Rough times: Seedance 1 to 5 minutes, Grok about a minute, HeyGen under a minute for short
clips. A video that has not finished after 25 minutes is marked failed.

**Seedance prices** (default list price, credits per second of the finished clip). The first
number is for `16:9`, `4:3`, `1:1`, `3:4` and `9:16`; the second is for `21:9` and `9:21`:

| Model | `480p` | `720p` | `1080p` | `4k` |
|---|---|---|---|---|
| `seedance-2-0-mini` | 7.1 / 9.4 | 16 / 21 | | |
| `seedance-2-0-fast` | 8.6 / 11.2 | 19.2 / 25.2 | | |
| `seedance-2-0` | 14.2 / 18.7 | 32 / 41.9 | 79 / 103.7 | 164.1 / 215.4 |
| `seedance-2-5` | 22.3 / 22.7 | 49.1 / 49.1 | | |

Pictures and reference videos do not add to the price. So a 15 second `480p` `9:16` Mini clip is
about 107 credits, and a 5 second one about 36.

**HeyGen prices** (default list price, credits per second). `text` and `first-frame` are the
standard rate; `reference` costs more, and its pictures add a little (billed as extra seconds):

| Resolution | `text` / `first-frame` | `reference` |
|---|---|---|
| `480p` | 4.3 | 14.8 |
| `768p` | 7.6 | 21.1 |
| `2k` | 21.1 | 38 |

In `reference` mode the pictures add, at the reference rate: at `480p` 1 second for one picture and
2 for two or three; at `768p` 1 second for one or two and 2 for three; at `2k` 1 second for one to
three. So an 8 second `768p` clip is about 61 credits; in `reference` mode with one picture about
190, with three about 211.

**Grok prices** (default list price), the same for both Grok models: `480p` 4, `720p` 7, `1080p`
9.6 credits per second.

---

### `POST /v1/video/frame` (sync, a few seconds, free)

Cuts one still out of a finished video at the video's own resolution and saves it, so the link
lasts. Use it to carry a scene on: the last frame of one clip becomes the opening picture of the
next (`heygen-video-1` with `heygenMode: "first-frame"`, the standard price).

| Field | Type | Notes |
|---|---|---|
| `videoUrl` | string | Required. A public https link to a finished video, such as `result.videoUrl`. Up to 200 MB. |
| `at` | string or number | `"last"` (default), `"first"`, or seconds from the start (0 to 600). |

Returns `200 { imageUrl, at }`. A time past the end of the video returns 400. If it is busy with
other frames it returns 429: try again in a few seconds.

---

### `POST /v1/script/generate` (sync, about 20 to 40 seconds)

Writes a Seedance ad script (Shot / Time / Prompt). If `userDirective` is 30 characters or longer it
first turns the story into beats, then writes one shot per beat.

| Field | Type | Notes |
|---|---|---|
| `vibe` | string | Required. UGC, Cinematic, Yapper, Documentary, Comedy and so on. |
| `vibeGuide` | object | `{ whatItIs, camera, audio, structure, protagonistRule, nativeFormat }` |
| `hookStyle` | string | The opening shot. |
| `setting` | string | Where the whole video takes place. |
| `duration` | number | Default 5. |
| `ratio` | string | Default `9:16`. |
| `productDetails` | string | Free text about the product. |
| `productUrl` | string | Optional. |
| `productNotes` | string | The output of `/v1/product/scan`, or your own notes. |
| `userDirective` | string | The story. 30 or more characters turns on the beat step (two text calls). |
| `narrativeData` | object | `{ storyIdea, characters, conflict, setting, goal, ending, toneReference }` |
| `brandVoice` | object | `{ personality, bannedPhrases, requiredPhrases, toneReference }` |
| `references` | object[] | `[{ url, type: 'image'\|'video'\|'audio', description? }]`. Pictures are looked at unless the beat step ran. |

The whole request can be up to 100,000 characters. Returns:

```json
{
  "rawText": "Shot: 1 ...\nTime: 0-3\nPrompt: ...",
  "scenes": [{ "scene": 1, "title": "...", "time_start": "0", "time_end": "3", "prompt": "..." }],
  "summary": "...",
  "style": "...",
  "requiredBeats": "BEAT 1 (0.0-2.0s): ..."
}
```

`requiredBeats` is `null` when the beat step did not run. Pass `rawText` as the `prompt` to
`/v1/video/generate` for Seedance.

---

### `POST /v1/directive/expand` (sync, about 5 seconds)

Body: `{ "userDirective": "...", "productNotes": "...", "duration": 5 }`. `userDirective` needs at
least 10 characters.

Returns `{ "beats": "BEAT 1 (0.0-X.Xs): ...\nBEAT 2 ..." }`.

---

### `POST /v1/product/scan` (sync, about 5 to 15 seconds)

```json
{
  "images": [{ "url": "https://..." }],
  "productDetails": "optional free text",
  "productUrl": "optional"
}
```

`images` can hold https links or data URLs. Returns
`{ "productNotes": "@image1 NOTES:\n- Type: ...\nCUSTOMER PERSONA:\n- Classification: ..." }`.

---

### `POST /v1/product/extract` (sync, free)

Body: `{ "url": "https://shop.example.com/products/..." }`. Returns
`{ title, productUrl, images: [{ url }], source }`, where `source` says how the images were found
(`shopify-json`, `og-meta`, `json-ld` or `html-scrape`). Pass `images[].url` straight into
`/v1/product/scan` or into `sources` on `/v1/image/generate`.

---

### `POST /v1/image/analyze` (streamed)

Body: `{ "image": "data:image/png;base64,..." }`. The picture must be a data URL. The reply is one
JSON object per line: progress lines, then a final
`{ "result": { detectedSubject, lighting, backdrop, surface, palette, props, composition, mood, preservationDirectives, stylePrompt } }`,
or a line with `error`. `stylePrompt` is ready to use in an image prompt.

---

### `POST /v1/video/analyze` (streamed)

Body: `{ "url": "https://...", "start": 0, "end": 15 }`. The video can be up to 100 MB; at most 120
seconds between `start` and `end` are looked at. The reply is one JSON object per line: progress
lines, then
`{ "result": { whatsHappening, vibeDNA, styleLine, sceneStructure: [{ beat, description, lever, timeApprox }], audioDNA, productionFormat, clonePrompt, cloneSeconds } }`,
or a line with `error`. `clonePrompt` is a ready video prompt that recreates the clip with `seedance-2-0-mini`, written
for `cloneSeconds` seconds (4 to 15); it can be missing if the analysis could not write one.

---

### `POST /v1/upload` (free)

Turns image bytes, or a link, into a temporary public link. Send ONE of:

```json
{ "dataUrl": "data:image/png;base64,iVBORw0..." }
```
```json
{ "sourceUrl": "https://..." }
```

Files can be up to 40 MB. Returns `{ "url": "https://..." }`, a temporary public link that lasts a
few hours.

**You usually do not need this:** the generate endpoints accept data URLs directly. Use it when you
want one link to reuse across many calls.

---

### `POST /v1/gemini/chat` (sync)

A raw call to the text and vision model, for anything the other endpoints do not cover.

```json
{
  "parts": [{ "text": "Write three ad headlines for a candle" }, { "image_url": { "url": "https://..." } }],
  "temperature": 0.8,
  "maxTokens": 4096
}
```

Up to 100,000 characters of text and 10 pictures. `maxTokens` is 1 to 16,384 (default 16,384).
Returns `{ "text": "..." }`.

---

### `GET /v1/jobs/:id`

```json
{
  "id": "...",
  "type": "image.generate",
  "status": "running",
  "createdAt": 1731700000000,
  "updatedAt": 1731700045000,
  "progress": "submitting",
  "input": { "model": "gpt-image-2.5-sunburst", "ratio": "1:1", "resolution": "2k" },
  "result": { "imageUrl": "https://app.shinestudio.ai/m/..." },
  "error": "..."
}
```

- `type`: `image.generate` or `video.generate`.
- `status`: `queued`, `running`, `success` or `failed`.
- `result.imageUrl` or `result.videoUrl` appears on `success`. `error` appears on `failed`.
- Other fields may appear. They are internal, so do not rely on them.

A job ID lasts six hours. It survives server restarts. After that, find the result with
`GET /v1/generations`. Jobs are private: another account's job ID returns 404.

---

### `GET /v1/generations` (your history)

Every finished generation, newest first, whether it was made through the API or in the app. Both
write the same record, so this list and the in-app gallery always agree. Use it to recover a result
when you have lost the job ID.

| Query | Default | Notes |
|---|---|---|
| `type` | `all` | `image`, `video` or `all` |
| `limit` | 50 | up to 200 |
| `cursor` | none | the `nextCursor` from the previous page |

```json
{
  "generations": [
    { "id": "...", "jobId": "...", "type": "image", "status": "success",
      "model": "GPT_IMAGE_25_SUNBURST", "prompt": "...", "promptTruncated": false,
      "resolution": "2k", "quality": "medium", "ratio": "1:1",
      "resultUrl": "https://app.shinestudio.ai/m/...", "source": "api",
      "createdAt": 1731700000000, "expiresAt": 1733000000000, "expired": false }
  ],
  "nextCursor": 1731600000000,
  "hasMore": true
}
```

Prompts are cut to 500 characters; `promptTruncated` says when that happened.

### How long a result link lasts

Result links are on ShineStudio's own address, for example `https://app.shinestudio.ai/m/...`.
They can expire: `expiresAt` is when the link stops working (`null` when it is kept while your plan
is active) and `expired` says whether that has already happened, so check it before fetching instead
of retrying a dead link.

Results are also saved to your account's gallery, and both follow the same rules: with an active
monthly plan, results are kept while the plan is active (and for 30 more days after it ends).
Without a plan, they are kept for 15 days. Results made before November 23, 2026 were stored the
old way and may expire sooner. **An expired link cannot be brought back.** If you need a result to
last forever, download it while `expired` is `false` and keep your own copy. Frames from `/v1/video/frame` are saved to your account and do not expire this way.

---

### Library endpoints

All need a key and only ever see your own account's data.

#### Library asset codes

Every picture in the Product Library has a permanent code: a folder letter plus a number, like
`B5`. Folder letters run `A` to `Z`, then `AA` to `ZZ`, then `AAA`. Codes are issued once and
**never reused**: delete a folder and its letter is retired for good, and rearranging never
renumbers anything.

`GET /v1/library/assets`:

```json
{ "assets": [
  { "code": "B5", "folder": "Gift Boxes", "folderCode": "B", "name": "box-front.png",
    "type": "image", "note": "", "url": "https://..." }
], "count": 1 }
```

Pass codes straight to `/v1/video/generate` in `references` (array order sets the tag, the first is
`@image1`). The image tools on the AI connector take codes in `sources` too.

#### Snapshot
- `GET /v1/library` → `{ folders, prompts, vibes, hookSetting }`

#### Folders (Product Library)
- `GET /v1/library/folders` → `{ folders: [...] }`
- `GET /v1/library/folders/:id`
- `POST /v1/library/folders`: body `{ name, files?, urlEntries?, productUrl?, productDetails?, pinned? }`. Returns the new folder with its `id` (201).
- `PATCH /v1/library/folders/:id`: body, any of `{ name, pinned, files, urlEntries, savedVibes, customVibe, vibeNote, customVibes, savedBrandVoices, productUrl, productDetails }`
- `DELETE /v1/library/folders/:id` → `{ deleted: true }`

#### Prompt templates
- `GET /v1/library/prompts` → `{ templates: [...] }`
- `POST /v1/library/prompts`: body `{ title, prompt, thumbnailUrl?, kind?: 'image'|'video' }` (title up to 255 characters, prompt up to 10,000)
- `DELETE /v1/library/prompts/:id`

#### Vibe customizations
- `GET /v1/library/vibes` → `{ vibes: [...] }`
- `PUT /v1/library/vibes/:vibeId`: body `{ castingBrief?, sceneLogic?, hookFormula?, productAdaptation? }` (each up to 10,000 characters)
- `DELETE /v1/library/vibes/:vibeId`

#### Hook and setting library
- `GET /v1/library/hook-setting` → `{ customHooks: [...], customSettings: [...], defaultHookThumbs: {}, defaultSettingThumbs: {} }`
- `PUT /v1/library/hook-setting`: body, any of `{ customHooks, customSettings, defaultHookThumbs, defaultSettingThumbs }`

---

## Cookbook

### Make ads from a product page
```bash
# 1) Pull the product images
PRODUCT=$(curl -sf -X POST https://app.shinestudio.ai/v1/product/extract \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"url":"https://shop.example.com/products/cool-thing"}')
IMG=$(echo "$PRODUCT" | jq -r .images[0].url)

# 2) Understand the product
NOTES=$(curl -sf -X POST https://app.shinestudio.ai/v1/product/scan \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"images\":[{\"url\":\"$IMG\"}],\"productDetails\":$(echo "$PRODUCT" | jq .title)}")

# 3) Make an ad image from it
curl -sf -X POST https://app.shinestudio.ai/v1/image/generate \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"prompt\":\"premium product photography, soft warm lighting\",\"ratio\":\"4:5\",\"model\":\"gpt-image-2.5-sunburst\",\"mode\":\"image-to-image\",\"sources\":[\"$IMG\"]}"
```

### Make a video ad from scratch
```bash
# 1) Write a script
SCRIPT=$(curl -sf -X POST https://app.shinestudio.ai/v1/script/generate \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"vibe":"UGC","hookStyle":"Product Hit","setting":"Bedroom","duration":5,"ratio":"9:16","productDetails":"a heart-shaped gift box from Bright Gifts Co","userDirective":"husband surprises his wife with the gift on a quiet Sunday morning"}')
PROMPT=$(echo "$SCRIPT" | jq -r .rawText)

# 2) Make the video
JOB=$(curl -sf -X POST https://app.shinestudio.ai/v1/video/generate \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"prompt\":$(jq -Rsa . <<< "$PROMPT"),\"model\":\"seedance-2-0-fast\",\"aspectRatio\":\"9:16\",\"duration\":5}" | jq -r .jobId)

# 3) Wait for it
while true; do
  STATUS=$(curl -sf -H "Authorization: Bearer $KEY" https://app.shinestudio.ai/v1/jobs/$JOB | jq -r .status)
  [ "$STATUS" = "success" ] && break
  [ "$STATUS" = "failed" ] && exit 1
  sleep 30
done
curl -sf -H "Authorization: Bearer $KEY" https://app.shinestudio.ai/v1/jobs/$JOB | jq -r .result.videoUrl
```

### Open a HeyGen clip on your product photo (first frame, 8 seconds, with sound)
```bash
JOB=$(curl -sf -X POST https://app.shinestudio.ai/v1/video/generate \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{
    "prompt": "The gift box sits on a kitchen table; a woman picks it up and smiles. The camera stays still.",
    "model": "heygen-video-1",
    "heygenMode": "first-frame",
    "imageUrls": ["https://example.com/product.png"],
    "resolution": "768p",
    "aspectRatio": "9:16",
    "duration": 8
  }' | jq -r .jobId)
# then check /v1/jobs/$JOB every 5 to 15 seconds as above
```
For lip-sync, use `"heygenMode": "reference"` with up to 3 pictures in `imageUrls` and one voice
clip in `audioUrls` (the `reference` rate plus the picture charge).

### Animate a product picture with Grok (8 seconds)
```bash
curl -sf -X POST https://app.shinestudio.ai/v1/video/generate \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{
    "prompt": "slow cinematic push-in on the product, dramatic lighting",
    "model": "grok-video",
    "imageUrls": ["https://example.com/product.png"],
    "aspectRatio": "1:1",
    "resolution": "720p",
    "duration": 8,
    "grokStyle": "normal"
  }' | jq -r .jobId
```

### Carry a scene on: the last frame of one HeyGen clip opens the next
```bash
# $VIDEO is result.videoUrl of the finished first clip
FRAME=$(curl -sf -X POST https://app.shinestudio.ai/v1/video/frame \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"videoUrl\": \"$VIDEO\", \"at\": \"last\"}" | jq -r .imageUrl)

curl -sf -X POST https://app.shinestudio.ai/v1/video/generate \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"model\": \"heygen-video-1\", \"heygenMode\": \"first-frame\", \"imageUrls\": [\"$FRAME\"], \"duration\": 8, \"resolution\": \"768p\", \"prompt\": \"She sets the box down and smiles. The camera stays still.\"}" | jq -r .jobId
```

### Remove the background, then upscale to 4K
```bash
# $IMAGE_URL is result.imageUrl of a finished image job
CUT=$(curl -sf -X POST https://app.shinestudio.ai/v1/bg-remove \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"imageUrl\":\"$IMAGE_URL\"}" | jq -r .url)

curl -sf -X POST https://app.shinestudio.ai/v1/upscale \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"imageUrl\":\"$CUT\",\"targetResolution\":\"4k\"}"
```

### Copy the vibe of a winning ad
```bash
# The reply is one JSON object per line; the last one holds the result.
ANALYSIS=$(curl -sf -X POST https://app.shinestudio.ai/v1/video/analyze \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d '{"url":"https://example.com/winning-ad.mp4","start":0,"end":15}' | tail -n 1)

echo "$ANALYSIS" | jq -r .result.vibeDNA      # camera, pacing, mood
echo "$ANALYSIS" | jq -r .result.styleLine    # one style line
echo "$ANALYSIS" | jq -r .result.audioDNA     # the audio brief
# Then call /v1/script/generate with narrativeData.toneReference set to styleLine, and so on.
```

---

## Limits and gotchas

- **No webhooks.** Check `/v1/jobs/:id`.
- **Jobs are short, history is not.** A job ID lasts six hours; `GET /v1/generations` keeps every
  finished image and video. Result links can still expire, so download what you want to keep.
- **Never resubmit a job that is still running.** A second call is a second charge.
- **The content filter** can refuse a prompt. The job fails with an error and the credits are
  refunded. Rephrase and try again.
- **The older local (stdio) MCP server** is no longer supported. Use the remote connector at
  `https://app.shinestudio.ai/mcp`.
