模型列表與單次呼叫帳單

模型列表與單次呼叫帳單

GET /v1/models 回傳帶價格、上下文與能力的結構化模型列表;GET /v1/generation 依請求 ID 查詢單次呼叫的 token 數與實際費用。

欄位值
Base URLhttps://token.easyapi.com/v1
認證Authorization: Bearer `API_KEY`
格式OpenAI 相容,擴充欄位對齊 OpenRouter
計費兩個介面本身不計費
注意: /v1/models 的價格依目前 API Key 所在分組折算,單位為 USD / token,以字串回傳。每個回應都帶 X-EasyAPI-Request-Id 標頭,用它呼叫 /v1/generation。消費紀錄在請求結束後寫入,緊接著查詢可能回傳 404,稍等片刻重試即可。

取得模型列表

GEThttps://token.easyapi.com/v1/models

回傳目前 Key 可用的模型。除 OpenAI 原生的 id / object / created / owned_by 外,每個模型還帶價格、上下文長度、輸入輸出模態、支援的參數、能力位與可呼叫端點,用戶端可直接用來顯示價格和上下文。

請求參數

名稱位置類型必選說明
Authorizationheaderstring是EasyAPI API Key。格式:Bearer `API_KEY`

返回欄位說明

名稱類型說明
idstring模型 ID,呼叫時填 model 欄位
namestring顯示名
categorystring分類:text / image / audio / video / embedding / rerank
context_lengthinteger上下文視窗(token);未知時省略
architecture.modalitystring輸入輸出模態,如 text+image->text
top_provider.max_completion_tokensinteger單次最大輸出 token 數
pricing.promptstring每輸入 token 價格(USD,字串),已依 Key 分組折算
pricing.completionstring每輸出 token 價格(USD)
pricing.input_cache_readstring快取命中輸入 token 價格(USD);模型不支援快取時省略
pricing.requeststring按次計費單價(USD);按量模型為 "0"
billing.groupstring本次計價採用的分組;搭配 model_ratio / group_ratio 可核對價格
supported_parametersarray<string>該模型接受的請求參數名
capabilitiesobject能力位:stream / tools / vision / json_mode / parallel_tool_calls(僅文字模型)
endpointsarray<object>可直接呼叫的端點:type / path / method
deprecationobject下線資訊: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" }
      ]
    }
  ]
}

查詢單次呼叫帳單

GEThttps://token.easyapi.com/v1/generation

示例請求: https://token.easyapi.com/v1/generation?id=2026100812000000a1b2c3

依請求 ID 回傳單次呼叫的 token 數、快取 token、最終扣費(USD)、倍率快照與耗時,只能查詢目前 Key 所屬帳號的呼叫。想在回應裡直接拿到費用,可在請求體加 usage.include = true,usage 物件會多一個 cost 欄位;該值為寫出前的估算,以本介面為準。

請求參數

名稱位置類型必選說明
Authorizationheaderstring是EasyAPI API Key。格式:Bearer `API_KEY`
idquerystring是請求 ID,來自回應標頭 X-EasyAPI-Request-Id

返回欄位說明

名稱類型說明
idstring請求 ID
modelstring呼叫的模型
created_atinteger紀錄時間(unix 秒)
is_streamboolean是否串流
tokens_promptinteger輸入 token 數
tokens_completioninteger輸出 token 數
native_tokens_cachedinteger快取命中的輸入 token 數
native_tokens_cache_writeinteger寫入快取的 token 數
total_costnumber最終扣費(USD)
quotainteger內部額度,500000 = 1 USD
generation_timeinteger整個請求耗時(ms,秒級精度)
latencyinteger首字延遲(ms),非串流為 0
billingobject結算用到的倍率快照: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參數錯誤缺少 idErrorResponse
401未認證API Key 無效ErrorResponse
404未找到紀錄尚未寫入,或該請求不屬於目前帳號;稍後重試ErrorResponse