跳轉到主要內容

快速開始

歡迎使用我們的API服務!本指南將幫助您快速開始使用圖像和視頻生成功能。

第一步:獲取API密鑰

  1. 訪問 API密鑰管理頁面
  2. 登錄您的賬戶
  3. 創建新的API密鑰
  4. 保存您的密鑰(密鑰只顯示一次)

第二步:選擇模型

我們提供多種AI模型供您選擇:

文字生成模型

  • GPT-4o: 強大的對話和文本生成能力
  • Claude: Anthropic 的高性能對話模型
  • Gemini: Google 的多模態大語言模型

圖像生成模型

  • GPT-4o-image: 高質量圖像生成
  • gpt-image-2: 支持 reference_images 的 OpenAI 兼容圖像生成

視頻生成模型

  • Sora2: 專業視頻生成

第三步:發送請求

文字生成示例

複製
curl -X POST https://toapis.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "你好,請介紹一下你自己"
      }
    ]
  }'

圖像生成示例

複製
curl -X POST https://toapis.com/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-image",
    "client_business_id": "order_20260428_001",
    "prompt": "一隻可愛的熊貓",
    "size": "1:1",
    "n": 1
  }'

視頻生成示例

複製
curl -X POST https://toapis.com/v1/videos/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "client_business_id": "order_20260428_002",
    "prompt": "海浪拍打着海岸",
    "duration": 15,
    "aspect_ratio": "16:9"
  }'

client_business_id 是您的業務 ID,例如訂單號、流水號或您系統內的任務 ID。創建圖片或視頻任務時傳入後,可用它查詢任務狀態: GET /v1/images/generations/{client_business_id}GET /v1/videos/generations/{client_business_id}

第四步:查詢任務狀態

由於我們使用異步處理模式,您需要查詢任務狀態來獲取結果: 複製
curl -X GET https://toapis.com/v1/images/generations/order_20260428_001 \
  -H "Authorization: Bearer YOUR_API_KEY"

下一步

查看 API 文檔

詳細瞭解所有可用的 API 接口。

Claude Code 集成

瞭解如何將 API 集成到您的開發工作流。