模型列表与单次调用账单
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 |