模型与发现
列出模型、能力、支持的参数与价格。
GET /v1/models 以兼容 OpenAI 的列表结构返回 OneHop 模型目录。每个条目都保留 OpenAI 的核心
字段 id、object 和 owned_by,所以严格的客户端无需理解更丰富的字段也能读 data[].id。
调用需要 API 密钥,但该端点不创建用量记录、不扣 Credit、也不向模型供应商转发请求。
curl https://api.onehop.ai/v1/models \
-H "Authorization: Bearer $ONEHOP_API_KEY"模型 slug
每个模型都有形如 provider/model 的规范 slug,例如 openai/gpt-5.5 或
anthropic/claude-opus-4.8。请原样使用 /v1/models 返回的 slug —— 你的
chat/completions、messages 和 images 请求里的 id 都应该用它。
别写死旗舰型号
模型可用性会随时间变化。请在启动时(或短暂缓存后)读取 /v1/models,而不是把某个
顶级模型 id 钉死在源码里。
使用 OpenAI SDK
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ONEHOP_API_KEY,
baseURL: "https://api.onehop.ai/v1",
});
const models = await client.models.list();
console.log(models.data.map((model) => model.id));要严格的 OpenAI 兼容结构:
curl "https://api.onehop.ai/v1/models?compat=openai" \
-H "Authorization: Bearer $ONEHOP_API_KEY"筛选与排序
常用筛选:
q:按 id、供应商、摘要或别名搜索id:精确模型 id、别名或供应商模型 idprovider或owned_by:供应商 slugprotocol:openai_chat、openai_responses、anthropic_messages、openai_images、openai_sora或google_vertex_aicapability:例如reasoning、tool_calling、vision或image_generationinput_modality/output_modality:例如text、image、audio或videosupported_parameter:例如tools、temperature、reasoning或max_tokens
分页与排序:
limit:默认100,最大500cursor:由next_cursor返回的游标sort:display_order、id、created_desc、context_desc、price_prompt_asc或price_completion_asc
价格字段
价格为生态兼容而暴露。OneHop 的计费真值在 onehop.pricing.our 下;
onehop.pricing.official 只是参考价。用 compat 视图对齐你的工具所期望的生态:
compat=openrouter增加pricing、architecture、top_provider和supported_parameters。compat=zenmux增加分组的pricings,如prompt、completion、input_cache_read、image、video或audio。include=pricing,capabilities,protocols,aliases在默认onehop视图上补各个分节。
curl "https://api.onehop.ai/v1/models?compat=openrouter&supported_parameter=tools" \
-H "Authorization: Bearer $ONEHOP_API_KEY"兼容 Anthropic 的列表
兼容 Anthropic 的模型发现在 /anthropic/v1/models,只列出支持 Anthropic Messages 协议的模型。
curl https://api.onehop.ai/anthropic/v1/models \
-H "x-api-key: $ONEHOP_API_KEY"