> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速開始

> 使用 ToAPIs 調用文字、圖像和視頻模型

> [!NOTE]
>
> **中國大陸用戶請注意：** 中國大陸用戶請使用 `https://toapis.cn` 作為接口地址（Base URL）。文檔示例中的 `https://toapis.com` 請替換為 `https://toapis.cn`。

ToAPIs 提供 OpenAI 相容的文字接口，以及統一的異步圖像、視頻生成接口。本指南使用目前可用的模型完成第一次調用。

## 第一步：取得 API 密鑰

1. 訪問 [API 密鑰管理頁面](https://toapis.com/dashboard/tokens)
2. 登入帳戶並建立 API 密鑰
3. 密鑰只顯示一次，請立即安全保存

## 第二步：選擇模型

| 類型 | 建議入門模型 | 說明 |
| - | - | - |
| 文字 | `gpt-5.6-terra` | 效能與成本均衡，適合一般對話和 Agent 工作流 |
| 圖像 | `gpt-image-2` | 支援文生圖和參考圖生成 |
| 視頻 | `seedance-2` | 支援文生視頻, 首尾幀圖生視頻和多模態參考生成 |

完整可用型號請以 [模型列表接口](https://docs.toapis.com/docs/zh-Hant/api-reference/chat/list-models.md) 和各模型文件為準。

## 第三步：發送請求

### 文字生成

```bash theme={null}
curl --request POST \
  --url https://toapis.com/v1/chat/completions \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-5.6-terra",
    "messages": [
      {"role": "user", "content": "你好，請介紹一下你自己"}
    ]
  }'
```

### 圖像生成

```bash theme={null}
curl --request POST \
  --url https://toapis.com/v1/images/generations \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-image-2",
    "prompt": "一隻可愛的熊貓，電影感光線",
    "size": "1:1",
    "resolution": "1k",
    "n": 1
  }'
```

### 視頻生成

```bash theme={null}
curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "seedance-2",
    "prompt": "海浪拍打著海岸，電影感鏡頭",
    "duration": 5,
    "aspect_ratio": "16:9",
    "resolution": "720p"
  }'
```

## 第四步：查詢異步任務

文字請求會直接返回結果；圖像和視頻請求會返回任務 ID。請按任務類型使用對應接口：

```bash theme={null}
# 圖像任務
curl https://toapis.com/v1/images/generations/YOUR_TASK_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

# 視頻任務
curl https://toapis.com/v1/videos/generations/YOUR_TASK_ID \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## 設定任務 Webhook

在 Token 編輯頁設定 HTTPS URL 並產生密鑰。任務可帶同源 `callback_url`；以 `X-ToAPIs-Webhook-*` 對 raw body 驗證 HMAC-SHA256，按 event ID 冪等，輪詢作後備。`429` 時讀取 `Retry-After`。參閱 [Webhook](https://docs.toapis.com/docs/zh-Hant/api-reference/webhooks/task-webhooks.md)。

## 下一步

> **[查看 API 文件](https://docs.toapis.com/docs/zh-Hant/index.md)**
>
> 查看全部接口、模型和參數。

> **[Claude Code 整合](https://docs.toapis.com/docs/zh-Hant/integrations/claude-code.md)**
>
> 在 Claude Code 中使用 ToAPIs。

> **[Codex 整合](https://docs.toapis.com/docs/zh-Hant/integrations/codex.md)**
>
> 透過 CC Switch 在 Codex 中使用 ToAPIs。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.