---
name: apistable
description: Use when building integrations with image, video, or music
  generation models. Reach for this skill when you need to submit media
  generation tasks, query results, manage files, handle webhooks, or integrate
  APIstable's model marketplace into applications or AI assistants.
metadata:
  mintlify-proj: apistable
  version: "1.0"
---

# APIstable Integration Skill

## Product summary

APIstable is a unified API for image, video, and music generation models from multiple providers (ByteDance, Google, OpenAI, Suno, and others). All models use the same asynchronous task API: submit a task with `POST /api/v1/tasks/create_task`, poll with `GET /api/v1/tasks/{task_id}`, and download results before they expire (14 days). Authentication uses Bearer tokens (`APISTABLE_API_KEY`). Key endpoints: `/api/v1/models` (list available models), `/api/v1/files/upload*` (upload media), `/api/v1/balance` (check credits). See [docs.apistable.ai](https://docs.apistable.ai) for complete reference.

## When to use

- **Submitting generation tasks**: User asks to generate images, videos, or music using specific models (e.g., "generate a video with Seedance 2.0")
- **Checking task status**: User needs to know if a generation is complete or retrieve results
- **Uploading reference media**: User provides files that need to be uploaded before creating a task (images for editing, audio for music operations)
- **Handling callbacks**: Building a webhook receiver to process task completion notifications
- **Checking credits**: User needs to know available balance before submitting expensive tasks
- **Integrating into applications**: Building server-side code that calls APIstable without MCP
- **Discovering available models**: User needs to know which models are currently live and their capabilities

## Quick reference

### Core endpoints

| Endpoint | Method | Purpose |
|----------|--------|---------|
| `/api/v1/tasks/create_task` | POST | Submit image, video, or music generation |
| `/api/v1/tasks/{task_id}` | GET | Query task status and results |
| `/api/v1/models` | GET | List available models (filter by `modality`: image, video, music, llm) |
| `/api/v1/models/{model_id}` | GET | Get exact input/output schemas for a model |
| `/api/v1/files/upload` | POST | Upload file (multipart, up to 500 MiB) |
| `/api/v1/files/upload_url` | POST | Register external URL (up to 500 MiB, 30s timeout) |
| `/api/v1/files/upload_base64` | POST | Upload base64 data (up to 10 MiB decoded) |
| `/api/v1/balance` | GET | Check available credits |

### Task lifecycle

1. **Create**: POST to `/api/v1/tasks/create_task` with `model` ID and model-specific `input` object
2. **Accept**: HTTP 200 returns `data.task_id` (acceptance only, not completion)
3. **Poll**: GET `/api/v1/tasks/{task_id}` until `status` is `succeeded` or `failed`
4. **Result**: On success, `data.result` is a JSON object; `data.input` is a JSON string
5. **Download**: Save output URLs before 14-day expiry; tasks unfinished after 24 hours are cleaned up free

### Authentication

```bash
export APISTABLE_API_KEY="your_api_key"
curl -H "Authorization: Bearer $APISTABLE_API_KEY" https://apistable.ai/api/v1/models
```

### Common request structure

```json
{
  "model": "nano-banana-2",
  "input": {
    "prompt": "A red fox in snow",
    "resolution": "1K",
    "aspect_ratio": "1:1",
    "output_count": 1
  },
  "callback_url": "https://example.com/webhook"
}
```

### File upload options

| Method | Limit | Use when |
|--------|-------|----------|
| `upload` | 500 MiB | Uploading local files via multipart |
| `upload_url` | 500 MiB | Referencing external URLs (≤100 MiB recommended) |
| `upload_base64` | 10 MiB decoded | Embedding small files in JSON |

All uploads return a `files.apistable.ai` URL valid for 24 hours.

## Decision guidance

### When to poll vs. use callbacks

| Approach | Use when | Pros | Cons |
|----------|----------|------|------|
| **Poll** | Simple scripts, testing, or no public HTTPS endpoint | No webhook setup needed | Higher latency, more API calls |
| **Callback** | Production apps, real-time updates needed | Immediate notification, fewer API calls | Requires webhook receiver, signature verification |

### When to use official_fallback

| Setting | Use when | Effect |
|---------|----------|--------|
| `official_fallback: false` (default) | Testing or specific provider required | Uses only the requested provider |
| `official_fallback: true` | Production, cost-sensitive, or provider unavailable | Falls back to compatible official channel if primary fails |

### File upload method selection

| Method | Use when |
|--------|----------|
| **upload** | You have a local file and can send multipart/form-data |
| **upload_url** | File is already hosted publicly (e.g., S3, CDN) |
| **upload_base64** | File is small (<10 MiB) and you're building JSON in code |

## Workflow

### Basic task submission

1. **Check availability**: Call `GET /api/v1/models` or `GET /api/v1/models/{model_id}` to confirm `live_available: true`
2. **Read schema**: Call `GET /api/v1/models/{model_id}?model_id=MODEL_ID` to get exact `input_schema` and `result_schema`
3. **Prepare input**: Build the model-specific `input` object (fields vary by model; check the model's doc page)
4. **Upload files** (if needed): Use `/api/v1/files/upload*` to get public URLs for reference images, audio, or video
5. **Submit task**: POST to `/api/v1/tasks/create_task` with `model`, `input`, and optional `callback_url`
6. **Save task_id**: Store `data.task_id` from the response
7. **Poll or wait**: Either poll `GET /api/v1/tasks/{task_id}` every 5–10 seconds, or wait for callback
8. **Check result**: When `status` is `succeeded`, parse `data.result` using the model's result schema
9. **Download**: Save output URLs before 14-day expiry
10. **Check charge**: Read `data.charged_credits` to see what was deducted

### Webhook receiver setup

1. **Get signing key**: Open Console → Settings → Webhook security, copy the key
2. **Store securely**: Set `APISTABLE_WEBHOOK_SECRET` environment variable (server-side only)
3. **Implement verification**: Use provided Node.js or Python code to verify HMAC-SHA256 signature
4. **Check timestamp**: Reject if `X-APIstable-Timestamp` is >300 seconds old
5. **Deduplicate**: Store `X-APIstable-Event-Id` with unique constraint; accept duplicates with 2xx
6. **Parse result**: Check `data.status` and parse `data.result` using model's schema
7. **Return 2xx**: Respond with HTTP 200–299 after durable acceptance

### Handling errors

1. **HTTP 401**: Invalid or revoked API key; check `APISTABLE_API_KEY`
2. **HTTP 402**: Insufficient credits; call `GET /api/v1/balance` to check available
3. **HTTP 400**: Invalid input (40001 JSON, 40002 input rejected, 40003 unsupported parameter); check model schema
4. **HTTP 503**: Model unavailable; no task created, no charge; check `live_available` before submitting
5. **HTTP 429**: Rate/concurrency limit; back off and retry
6. **Timeout on create**: Do not auto-retry; check recent tasks with `GET /api/v1/tasks` first

## Common gotchas

- **Do not auto-retry after uncertain network timeout on task creation**: Each accepted call creates a new task. If you're unsure whether a POST succeeded, query recent tasks first instead of resubmitting.
- **HTTP 200 on task creation means acceptance, not completion**: Always poll or use callbacks to check final status.
- **Keep API keys server-side only**: Never embed `APISTABLE_API_KEY` in client code, prompts, or repositories.
- **URLs expire after 14 days**: Download generated outputs immediately; tasks unfinished after 24 hours are cleaned up.
- **Uploaded files expire after 24 hours**: If you upload a file, use it in a task within 24 hours or re-upload.
- **Callback URLs must be public HTTPS with no redirects**: Private IPs and redirects are rejected.
- **Do not hex-decode the webhook signing key**: Use it as a UTF-8 string directly in HMAC-SHA256.
- **Do not re-serialize JSON before webhook verification**: Sign the raw request body bytes, not re-parsed JSON.
- **Place output_count and official_fallback inside input, not at top level**: These are model-specific and only supported by some models.
- **Idempotency keys and max_credits are not accepted**: The API does not support these fields.
- **Check live_available before submitting**: Disabled models return HTTP 503 without charging.
- **Keep reference URLs accessible until task completes**: If you pass `first_frame_url`, `reference_image_urls`, etc., the server must be able to fetch them while the task is processing.
- **LLM Chat Completions endpoint is not yet available**: Requests return HTTP 503; focus on image, video, and music models.

## Verification checklist

Before submitting work:

- [ ] Confirmed the model is `live_available: true` via `GET /api/v1/models/{model_id}`
- [ ] Read the model's exact `input_schema` and `result_schema` from the API or doc page
- [ ] Uploaded all reference files (images, audio, video) and have public HTTPS URLs
- [ ] Built the `input` object with all required fields for the chosen model
- [ ] Checked available credits with `GET /api/v1/balance` if task is expensive
- [ ] Submitted task with `POST /api/v1/tasks/create_task` and saved `task_id`
- [ ] Verified task status with `GET /api/v1/tasks/{task_id}` (or received callback)
- [ ] Confirmed `status` is `succeeded` (not `processing` or `failed`)
- [ ] Parsed `data.result` using the model's result schema
- [ ] Downloaded output URLs before 14-day expiry
- [ ] If using webhooks: verified signature with HMAC-SHA256, checked timestamp, deduplicated by event ID
- [ ] Checked `data.charged_credits` to confirm billing

## Resources

- **Comprehensive API reference**: [https://docs.apistable.ai/llms.txt](https://docs.apistable.ai/llms.txt) — page-by-page navigation of all endpoints and models
- **Quickstart**: [https://docs.apistable.ai/quickstart](https://docs.apistable.ai/quickstart) — step-by-step first request
- **API Directory**: [https://docs.apistable.ai/api-directory](https://docs.apistable.ai/api-directory) — all endpoints at a glance
- **Webhook Security**: [https://docs.apistable.ai/webhook-secret](https://docs.apistable.ai/webhook-secret) — signature verification code and deduplication

---

> For additional documentation and navigation, see: https://docs.apistable.ai/llms.txt