模型列表與單次呼叫帳單
GET /v1/models 回傳帶價格、上下文與能力的結構化模型列表;GET /v1/generation 依請求 ID 查詢單次呼叫的 token 數與實際費用。
注意: /v1/models 的價格依目前 API Key 所在分組折算,單位為 USD / token,以字串回傳。每個回應都帶 X-EasyAPI-Request-Id 標頭,用它呼叫 /v1/generation。消費紀錄在請求結束後寫入,緊接著查詢可能回傳 404,稍等片刻重試即可。
取得模型列表
GET
https://token.easyapi.com/v1/models回傳目前 Key 可用的模型。除 OpenAI 原生的 id / object / created / owned_by 外,每個模型還帶價格、上下文長度、輸入輸出模態、支援的參數、能力位與可呼叫端點,用戶端可直接用來顯示價格和上下文。
請求參數
| 名稱 | 位置 | 類型 | 必選 | 說明 |
|---|---|---|---|---|
Authorization | header | string | 是 | EasyAPI API Key。格式:Bearer `API_KEY` |
返回欄位說明
| 名稱 | 類型 | 說明 |
|---|---|---|
id | string | 模型 ID,呼叫時填 model 欄位 |
name | string | 顯示名 |
category | string | 分類:text / image / audio / video / embedding / rerank |
context_length | integer | 上下文視窗(token);未知時省略 |
architecture.modality | string | 輸入輸出模態,如 text+image->text |
top_provider.max_completion_tokens | integer | 單次最大輸出 token 數 |
pricing.prompt | string | 每輸入 token 價格(USD,字串),已依 Key 分組折算 |
pricing.completion | string | 每輸出 token 價格(USD) |
pricing.input_cache_read | string | 快取命中輸入 token 價格(USD);模型不支援快取時省略 |
pricing.request | string | 按次計費單價(USD);按量模型為 "0" |
billing.group | string | 本次計價採用的分組;搭配 model_ratio / group_ratio 可核對價格 |
supported_parameters | array<string> | 該模型接受的請求參數名 |
capabilities | object | 能力位:stream / tools / vision / json_mode / parallel_tool_calls(僅文字模型) |
endpoints | array<object> | 可直接呼叫的端點:type / path / method |
deprecation | object | 下線資訊:status(scheduled / offline)、offline_at、suggested_model;未計畫下線時省略 |
返回示例
{
"object": "list",
"data": [
{
"id": "gpt-4o",
"object": "model",
"created": 1759190400,
"owned_by": "openai",
"name": "gpt-4o",
"category": "text",
"context_length": 128000,
"architecture": {
"modality": "text+image->text",
"input_modalities": ["text", "image"],
"output_modalities": ["text"]
},
"top_provider": {
"context_length": 128000,
"max_completion_tokens": 16384,
"is_moderated": false
},
"pricing": {
"prompt": "0.0000025",
"completion": "0.00001",
"input_cache_read": "0.00000125",
"request": "0"
},
"billing": {
"mode": "token",
"group": "default",
"group_ratio": 1,
"model_ratio": 1.25,
"completion_ratio": 4
},
"supported_parameters": ["temperature", "top_p", "max_tokens", "stream", "tools", "tool_choice", "response_format"],
"capabilities": {
"stream": true,
"tools": true,
"vision": true,
"json_mode": true,
"parallel_tool_calls": true
},
"supported_endpoint_types": ["openai", "openai-response"],
"endpoints": [
{ "type": "openai", "path": "/v1/chat/completions", "method": "POST" },
{ "type": "openai-response", "path": "/v1/responses", "method": "POST" }
]
}
]
}查詢單次呼叫帳單
GET
https://token.easyapi.com/v1/generation示例請求: https://token.easyapi.com/v1/generation?id=2026100812000000a1b2c3
依請求 ID 回傳單次呼叫的 token 數、快取 token、最終扣費(USD)、倍率快照與耗時,只能查詢目前 Key 所屬帳號的呼叫。想在回應裡直接拿到費用,可在請求體加 usage.include = true,usage 物件會多一個 cost 欄位;該值為寫出前的估算,以本介面為準。
請求參數
| 名稱 | 位置 | 類型 | 必選 | 說明 |
|---|---|---|---|---|
Authorization | header | string | 是 | EasyAPI API Key。格式:Bearer `API_KEY` |
id | query | string | 是 | 請求 ID,來自回應標頭 X-EasyAPI-Request-Id |
返回欄位說明
| 名稱 | 類型 | 說明 |
|---|---|---|
id | string | 請求 ID |
model | string | 呼叫的模型 |
created_at | integer | 紀錄時間(unix 秒) |
is_stream | boolean | 是否串流 |
tokens_prompt | integer | 輸入 token 數 |
tokens_completion | integer | 輸出 token 數 |
native_tokens_cached | integer | 快取命中的輸入 token 數 |
native_tokens_cache_write | integer | 寫入快取的 token 數 |
total_cost | number | 最終扣費(USD) |
quota | integer | 內部額度,500000 = 1 USD |
generation_time | integer | 整個請求耗時(ms,秒級精度) |
latency | integer | 首字延遲(ms),非串流為 0 |
billing | object | 結算用到的倍率快照:model_ratio / completion_ratio / group_ratio / cache_ratio |
返回示例
{
"data": {
"id": "2026100812000000a1b2c3",
"model": "gpt-4o",
"created_at": 1759905600,
"is_stream": true,
"token_name": "my-key",
"group": "default",
"is_byok": false,
"tokens_prompt": 1000,
"tokens_completion": 200,
"total_tokens": 1200,
"native_tokens_cached": 80,
"native_tokens_cache_write": 0,
"total_cost": 0.0045,
"quota": 2250,
"generation_time": 3000,
"latency": 350,
"billing": {
"model_ratio": 1.25,
"completion_ratio": 4,
"group_ratio": 1,
"cache_ratio": 0.5
}
}
}返回結果
| 狀態碼 | 狀態碼含義 | 說明 | 資料模型 |
|---|---|---|---|
200 | 成功 | 回傳帳單 | GenerationResponse |
400 | 參數錯誤 | 缺少 id | ErrorResponse |
401 | 未認證 | API Key 無效 | ErrorResponse |
404 | 未找到 | 紀錄尚未寫入,或該請求不屬於目前帳號;稍後重試 | ErrorResponse |