OneHop Docs

模型与发现

列出模型、能力、支持的参数与价格。

GET /v1/models 以兼容 OpenAI 的列表结构返回 OneHop 模型目录。每个条目都保留 OpenAI 的核心 字段 idobjectowned_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.5anthropic/claude-opus-4.8。请原样使用 /v1/models 返回的 slug —— 你的 chat/completionsmessagesimages 请求里的 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、别名或供应商模型 id
  • providerowned_by:供应商 slug
  • protocol:openai_chatopenai_responsesanthropic_messagesopenai_imagesopenai_soragoogle_vertex_ai
  • capability:例如 reasoningtool_callingvisionimage_generation
  • input_modality / output_modality:例如 textimageaudiovideo
  • supported_parameter:例如 toolstemperaturereasoningmax_tokens

分页与排序:

  • limit:默认 100,最大 500
  • cursor:由 next_cursor 返回的游标
  • sort:display_orderidcreated_desccontext_descprice_prompt_ascprice_completion_asc

价格字段

价格为生态兼容而暴露。OneHop 的计费真值在 onehop.pricing.our 下; onehop.pricing.official 只是参考价。用 compat 视图对齐你的工具所期望的生态:

  • compat=openrouter 增加 pricingarchitecturetop_providersupported_parameters
  • compat=zenmux 增加分组的 pricings,如 promptcompletioninput_cache_readimagevideoaudio
  • 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"