ToAPIsToAPIs
定價與費用

查詢模型定價

按帳戶或自有 Key 視角查詢目前模型定價目錄

GET
/api/v1/pricing

中國大陸用戶請注意: 中國大陸用戶請使用 https://api.toapis.cn 作為接口地址 (Base URL). 文檔示例中的 https://api.toapis.com 請替換為 https://api.toapis.cn.

使用說明

查詢當前帳戶可用的模型定價目錄, 包括每個模型的計費方式和單價. 指定 api_key_id 可查看某個自有 Key 視角下的目錄. 與舊 GET /v1/pricing 共用同一套目錄計算, 但驗證方式, 參數和回應結構不同. 目錄反映當前費率, 不是生成請求的報價, 也不用於估算總價或鎖價.

實際扣費金額見實際費用與任務用量.

定價區域由帳戶決定, 不接受 region, group, after 或生成參數. 如果帳戶目前沒有任何有效定價區域, 回傳 503. 這個空結果不會儲存為帳戶的定價區域設定. 帳戶視角使用帳戶有效基礎群組. 指定 api_key_id 時額外套用目標 Key 的群組和模型限制.

目標 Key 已刪除, 屬於他人或帶 scope 時統一回傳 404, 群組不可用時回傳 403 (code=13003). meta.key_status 只說明目標 Key 的設定狀態, 不代表目前可用性.

完整目錄會略過無法確認價格的模型, 缺少價格不代表免費. 查詢指定 model 時: 不在可見目錄中回傳 404 (code=16008), 可見但暫無已確認價格回傳 503 (code=18029), 目錄相依服務不可用回傳 503 (code=18028). 設定變動可能使分頁游標失效, 同一分頁過程中也不保證價格快照一致.

驗證

Authorizationstring請求頭必填

系統存取權杖, 格式為 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 不接受模型 Key, 不需要 X-User-Id. 共用規則見接入方式.

請求參數

api_key_idstring查詢

可選的自有未刪除一般 Key 視角. 省略使用帳戶設定. 停用, 過期或耗盡的 Key 可查設定價格, 不表示目前可呼叫.

modelstring查詢

精確模型 ID, 最多 255 位元組.

typestring查詢

模型類型: image, video 或 audio.

limitinteger查詢預設值: 100

每頁數量, 預設 100, 範圍 1-100.

cursorstring查詢

上一頁 next_cursor, 最多 2048 位元組. 篩選或定價上下文變更後重新開始.

請求範例

請求示例

curl --request GET \
  --url 'https://api.toapis.com/api/v1/pricing?type=image&limit=20' \
  --header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'
import requests

response = requests.get(
    "https://api.toapis.com/api/v1/pricing",
    headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
    params={"type": "image", "limit": "20"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.toapis.com/api/v1/pricing?type=image&limit=20", {
  method: "GET",
  headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
  signal: AbortSignal.timeout(30_000),
});
if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());

回應欄位

範例使用虛構資料. 回應包裝與錯誤處理見接入方式.

data.itemsarray

包含 id, type 及 prices 的模型清單.

data.meta.currencystring

幣別, 固定 USD.

data.meta.contextstring

定價視角: account 或 api_key.

data.meta.api_key_idstring | null

目標 Key ID, 帳戶視角為 null.

data.meta.key_statusstring | null

目標 Key 狀態, 帳戶視角為 null.

data.meta.regionstring

帳戶有效區域: cn 或 global.

data.has_moreboolean

是否還有下一頁.

data.next_cursorstring | null

下一頁游標, 最後一頁為 null.

prices[].groupstring

此價格適用的路由群組. 使用自動群組的 API Key 可能收到多個群組.

prices[].conditionsobject

價格成立的條件, 包含會影響計價的模型預設值. 生成請求應與這些值相符.

prices[].charge_typestring

計費類型: per_request, per_second 或 per_token.

prices[].price_basisstring

計費依據: request, output_seconds, output_videos, total_tokens 或 text_input_tokens.

prices[].unitstring

價格單位: request, second, video 或 1m_tokens.

prices[].unit_pricestring

以十進位字串回傳的 USD 生效單價. 此價格已包含客戶價格和群組倍率, 不要再次乘上群組倍率.

價格也可能包含 input_unit_price, input_image_unit_price, free_input_image_count, minimum_charge_usd 或 image_token_prices.

分時計價也可能包含 pricing_period, pricing_timezone, pricing_schedule_version 和 pricing_peak_windows.

圖片 token 計價中的 image_token_prices 可包含 text_input, cached_text_input, image_input, cached_image_input 和 image_output. 每項金額單位均為每 100 萬 tokens 的 USD 價格.

回應範例

響應示例

{
  "code": 0,
  "message": "",
  "data": {
    "items": [
      {
        "id": "example-image-model",
        "type": "image",
        "prices": [
          {
            "charge_type": "per_request",
            "unit": "request",
            "unit_price": "0.05",
            "price_basis": "request",
            "group": "default",
            "conditions": {
              "size": "1024x1024"
            }
          }
        ]
      }
    ],
    "has_more": false,
    "next_cursor": null,
    "meta": {
      "currency": "USD",
      "context": "account",
      "api_key_id": null,
      "key_status": null,
      "region": "global"
    }
  }
}