模型列表与单次调用账单

模型列表与单次调用账单

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