# MAGI-2 Official Native & Ark-Compatible Protocol

Point your Sand.ai client or Ark SDK Base URL to this platform and replace the API key to call MAGI-2 directly. [Sand.ai Docs](https://platform.sand.ai/docs/get-started)

> [!NOTE]
> Example model IDs are for reference only; use actual IDs from the [Model Marketplace](/models).

### 1. Official Endpoints
* **Native Submit / Poll**: `POST /v2/generations` · `GET /v2/generations/{id}`
* **Ark-Compatible Submit / Poll**: `POST /compatible/ark/api/v3/contents/generations/tasks` · `GET /compatible/ark/api/v3/contents/generations/tasks/{id}`
* **Auth Header**: `Authorization: Bearer sk-your_token_here`

### 2. Statuses & Key Constraints
* **Native Statuses (`/v2/generations/{id}`)**: `queued`, `processing`, `succeeded` (video in `output.videoUrl`), `failed`, `canceled`.
* **Ark Statuses (`/compatible/ark/.../{id}`)**: `queued`, `running`, `succeeded` (video in `content.video_url`), `failed`, `cancelled`, `expired`.
* **Constraints**: Fixed `1080p`, integer `duration` `4`–`30`s, audio enabled by default, public `https://` media URLs only; omit `watermark` and unsupported Ark-only fields; completed tasks return auth-free direct URLs.

### 3. Examples

#### A. Sand.ai Native Omni-Reference (`POST /v2/generations`)
```bash
curl -X POST https://www.roookey.com/v2/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "parts": [
      { "type": "text", "text": "A crimson-robed dancer along a stone alley with guqin accompaniment" },
      { "type": "reference_image", "image": { "url": "https://example.com/dancer.png" } },
      { "type": "reference_audio", "audio": { "url": "https://example.com/guqin.mp3" } }
    ],
    "duration": 6,
    "aspectRatio": "16:9",
    "generateAudio": true
  }'
```

#### B. Ark-Compatible First & Last Frame (`POST /compatible/ark/api/v3/contents/generations/tasks`)
```bash
curl -X POST https://www.roookey.com/compatible/ark/api/v3/contents/generations/tasks \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "content": [
      { "type": "text", "text": "Morning mist lifts as the camera glides toward a sunlit lake" },
      { "type": "image_url", "image_url": { "url": "https://example.com/start.png" }, "role": "first_frame" },
      { "type": "image_url", "image_url": { "url": "https://example.com/end.png" }, "role": "last_frame" }
    ],
    "duration": 5,
    "ratio": "16:9"
  }'
```

> [!TIP]
> For official Ark SDKs, set `base_url` to `https://www.roookey.com/compatible/ark/api/v3`; poll via `GET /v2/generations/{id}` or `/compatible/ark/api/v3/contents/generations/tasks/{id}`.
