# Quickstart & Conventions

**LLM-friendly index:** [https://docs.brioi.com/english/llms.txt](https://docs.brioi.com/english/llms.txt) — pass this URL directly to AI coding assistants and agents.

Brioi provides a unified API for text, image, video, and text-to-speech (TTS) generation. Before integrating, query the live model list with your API key to verify model availability.

> This page covers conventions shared across all endpoints. Where a model-specific guide differs from this page, the model-specific guide takes precedence.

## Getting Started

- **Base origin:** `https://vip.brioi.com`
- **Default authentication header:** `Authorization: Bearer YOUR_API_KEY`
- **Default content type:** `application/json` (except multipart file-upload endpoints)
- **Live model list:** `GET /v1/models`

```bash
curl "https://vip.brioi.com/v1/models" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Never expose your API key in client-side code, public repositories, or logs.

### Base URL by SDK & Client

Different SDKs automatically append their own path prefixes. Configure the exact Base URL shown below to avoid double-prefixing `/v1/v1` and triggering `404` errors:

| Integration / Client | Base URL | Authentication |
|---|---|---|
| Official OpenAI SDK / OpenAI-compatible clients / Codex | `https://vip.brioi.com/v1` | `Authorization: Bearer YOUR_API_KEY` |
| Official Anthropic SDK / Claude Code / CC Switch (Claude) | `https://vip.brioi.com` (omit `/v1`) | `x-api-key: YOUR_API_KEY` or `Bearer` |
| Google Gen AI SDK / Gemini CLI | `https://vip.brioi.com` (omit `/v1beta`) | `x-goog-api-key: YOUR_API_KEY` or `Bearer` |
| Raw HTTP / cURL | `https://vip.brioi.com` + full endpoint path | As specified in each model guide |

### API Key Groups & Model Visibility

- The `model` value in every request must appear in the live `GET /v1/models` response for that API key (except [Midjourney Image Generation](https://docs.brioi.com/english/2552257m0.md), where operations are routed via `/mj/*` paths without a `model` field).
- When creating an API key, we recommend selecting the `auto` group by default—it covers mainstream text, general image/video, and Seedance per-second and Volcengine-native models. Models in dedicated groups require a key assigned to that group, such as `Kimi`, `GLM`, `Grok`, or `Claude｜对话` (chat-only Claude group); check the Model Marketplace and API Keys pages in the `vip.brioi.com` console for exact coverage.
- `GET /v1/models` returns text, image, video, and TTS models together. **Image, video, and TTS models cannot be called via `/v1/chat/completions`**—always use the dedicated endpoint documented for each model. Selecting non-text models in a standard chat client will fail.
- Send only the fields documented for the target model. Do not pass chat fields such as `messages`, `temperature`, `top_p`, or `stream` to image or video endpoints.

## Asynchronous Tasks

Asynchronous task paths and status enums are scoped by endpoint protocol. Task IDs cannot be mixed across protocols (for example, polling an image task ID at `/v1/videos/{task_id}` returns an error).

- **Async Image API** (`/v1/images/async/*`) and **Unified Video API** (`/v1/videos`) follow the two tables below.
- **[Seedance Volcengine Native Video Generation](https://docs.brioi.com/english/2552266m0.md)** (`/api/v3/contents/generations/tasks`), **[Midjourney Image Generation](https://docs.brioi.com/english/2552257m0.md)** (`/mj/*`), and **[Seedance Asset Registration](https://docs.brioi.com/english/2552264m0.md)** (`/v1/realperson`) each use independent native task paths and status values—see their respective guides.

### Async Image Tasks (`/v1/images/async/*`)

| Item | Convention |
|---|---|
| Task ID | `task_id` from the creation response |
| In progress | `SUBMITTED`, `IN_PROGRESS` — continue polling |
| Succeeded | `SUCCESS` — read `images[].url` |
| Failed | `FAILURE` — read `fail_reason` |
| Poll interval | 3–5 seconds |

### Video Tasks (`/v1/videos`)

| Item | Convention |
|---|---|
| Task ID | `id` from the creation response, passed as `{task_id}` in the polling URL. Some responses also echo an identical `task_id` field for backward compatibility only. |
| In progress | `queued`, `in_progress` — continue polling |
| Succeeded | `completed` — read `metadata.url` |
| Failed | `failed` — read `error.code` and `error.message` |
| Poll interval | 5–10 seconds (unless a model guide specifies otherwise) |

Auxiliary fields in video polling responses vary by model. Clients should depend only on `id`, `status`, `metadata.url`, and `error`; fields such as `object`, `model`, `progress`, and `seconds` may be omitted. Some responses also include `result_url` with the same value as `metadata.url`, which can be used as a fallback. Treat any status value not listed above as in-progress and continue polling.

### Polling & Retries

- Receiving HTTP `200`, a task ID, or a non-terminal status from a creation endpoint means only that the task has entered the processing pipeline—not that media generation has completed.
- On a single poll timeout or transient `5xx` error, retry polling with the same task ID rather than creating a new task.
- If the creation request itself times out or returns `5xx`, verify whether the task was created before submitting a duplicate request.
- Do not treat a success status with an empty result URL as a deliverable completion; retain the task ID and raw response payload for troubleshooting.

## Input Media & Result URLs

- Unless a model guide states otherwise, input assets must be publicly accessible direct `HTTPS` URLs that serve the raw media file without login, cookies, or custom headers.
- MIME types, file sizes, resolutions, durations, and asset counts must comply with the target model guide.
- Pre-signed input URLs must remain valid for the entire duration of task processing.
- Generated result URLs expire, after which polling responses may omit them. Download or copy output files to your own storage immediately once a task succeeds.

## Error Handling

| HTTP Status | Meaning |
|---:|---|
| `400` | Invalid request parameters or malformed JSON; also returned when a video task does not exist (`code` is `task_not_exist`) |
| `401` | Missing or invalid API key |
| `403` | Insufficient balance or key quota, or the API key lacks group/model permission |
| `404` | Async image task not found, or malformed URL path (such as duplicate `/v1/v1`) |
| `429` | Rate limit exceeded |
| `503` | Service temporarily unavailable |
| `500`, `502` | Transient server or upstream error |

Synchronous endpoints and task creation requests typically return errors in this format:

```json
{
  "error": {
    "code": "error_code",
    "message": "Error description (request id: 2026xxxxxxxxxxxxxxxx)",
    "type": "new_api_error"
  }
}
```

Video task polling endpoints use the following error envelope:

```json
{
  "code": "task_not_exist",
  "message": "task_not_exist",
  "data": null
}
```

Every response includes the `X-Oneapi-Request-Id` header, and most error `message` strings append the same request ID. Record the request ID, task ID, and error message when troubleshooting—never log API keys or full sensitive media URLs.

