> [!NOTE] > 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 > [English](./README.en.md) · [原始项目](https://github.com/anomalyco/models.dev) · [上游 README](https://github.com/anomalyco/models.dev/blob/HEAD/README.md) > 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
--- [Models.dev](https://models.dev) 是一个全面的开源 AI 模型规格、定价与能力数据库。 目前没有一个数据库能涵盖所有可用 AI 模型的信息。我们发起 Models.dev,作为一个社区贡献项目来解决这一问题。我们也在 [opencode](https://opencode.ai). 内部使用它。 ## API 你可以通过 API 访问这些数据。 ```bash curl https://models.dev/api.json ``` 使用 **Model ID** 字段查询任意模型;这是 [AI SDK](https://ai-sdk.dev/). 使用的标识符。 与提供商无关(provider-agnostic)的模型元数据可单独获取: ```bash curl https://models.dev/models.json ``` 用于获取模型本身的事实信息,与由何处提供服务无关。若需要在一个响应中同时获取提供商端点与仅含模型的元数据: ```bash curl https://models.dev/catalog.json ``` ### Logos 提供商标志以 SVG 文件形式提供: ```bash curl https://models.dev/logos/{provider}.svg ``` 将 `{provider}` 替换为 **Provider ID**(例如 `anthropic`、`openai`、`google`)。若我们没有某提供商的标志,将返回默认标志。 ## Contributing 数据以 TOML 文件形式存储在仓库中,按提供商和模型组织。标志存储为 SVG。这些内容用于生成本页面并驱动 API。 我们需要你的帮助来保持数据最新。 ### Adding Model Metadata 仅含模型的事实信息存放在 `models/`,使用与提供商模型相同的路径式 ID。例如,`models/openai/gpt-5.toml` 定义底层 GPT-5 模型的元数据,而 `providers/openai/models/gpt-5.toml` 定义 OpenAI 特定的服务详情(如定价)。 将模型元数据用于与提供商无关的事实: - `name`、`family`、`release_date`、`last_updated`、`knowledge` - `attachment`、`reasoning`、`tool_call`、`structured_output`、`temperature` - `[limit]` 默认值,如上下文、输入与输出 token 限制 - `[modalities]` 默认值 - `open_weights`、`license`、`links`、`weights` 以及 `benchmarks` 示例: ```toml name = "GPT-5" family = "gpt" release_date = "2025-08-07" last_updated = "2025-08-07" attachment = true reasoning = true temperature = false tool_call = true structured_output = true open_weights = false [limit] context = 400_000 input = 272_000 output = 128_000 [modalities] input = ["text", "image"] output = ["text"] [[benchmarks]] name = "Benchmark Name" score = 72.5 metric = "accuracy" source = "https://example.com/results" [[weights]] label = "Model weights" url = "https://huggingface.co/example/model" format = "safetensors" ``` 提供商 TOML 可通过 `base_model` 继承这些事实,然后仅保留提供商特定字段或覆盖项: ```toml base_model = "openai/gpt-5" [cost] input = 1.25 output = 10.00 cache_read = 0.125 [limit] context = 200_000 # optional provider override output = 32_000 ``` 生成时,提供商字段优先于模型元数据。当底层模型相同,但提供商以不同的上下文限制、模态、功能或定价提供服务时,请使用此方式。 ### Adding a New Provider Model 要添加新模型,请先检查该提供商是否已存在于 `providers/` 目录中。若不存在,则: #### 1. Create a Provider 若提供商尚未在 `providers/` 中: 1. 在 `providers/` 中创建一个以提供商 ID 命名的新文件夹。例如 `providers/newprovider/`。 2. 添加包含提供商详情的 `provider.toml`: ```toml name = "Provider Name" npm = "@ai-sdk/provider" # AI SDK Package name env = ["PROVIDER_API_KEY"] # Environment Variable keys used for auth doc = "https://example.com/docs/models" # Link to provider's documentation ``` 若提供商未发布 npm 包,但暴露了 OpenAI 兼容端点,请相应设置 npm 字段并包含 base URL: ```toml npm = "@ai-sdk/openai-compatible" # Use OpenAI-compatible SDK api = "https://api.example.com/v1" # Required with openai-compatible ``` #### 2. Add a Logo (optional) 要为提供商添加标志: 1. 在提供商目录中添加 `logo.svg` 文件(例如 `providers/newprovider/logo.svg`) 2. 使用 SVG 格式,不固定尺寸或颜色——填充/描边使用 `currentColor` SVG 结构示例: ```svg ``` #### 3. Add a Model Definition 在提供商的 `models/` 目录中创建新的 TOML 文件,文件名为模型 ID。 若模型 ID 包含 `/`,请使用子文件夹。例如,对于模型 ID `openai/gpt-5`,创建文件夹 `openai/`,并在其中放置名为 `gpt-5.toml` 的文件。 ```toml name = "Model Display Name" attachment = true # or false - supports file attachments reasoning = false # or true - supports reasoning / chain-of-thought tool_call = true # or false - supports tool calling structured_output = true # or false - supports a dedicated structured output feature temperature = true # or false - supports temperature control knowledge = "2024-04" # Knowledge-cutoff date release_date = "2025-02-19" # First public release date last_updated = "2025-02-19" # Most recent update date open_weights = true # or false - model’s trained weights are publicly available [cost] input = 3.00 # Cost per million input tokens (USD) output = 15.00 # Cost per million output tokens (USD) reasoning = 15.00 # Cost per million reasoning tokens (USD) cache_read = 0.30 # Cost per million cached read tokens (USD) cache_write = 3.75 # Cost per million cached write tokens (USD) input_audio = 1.00 # Cost per million audio input tokens (USD) output_audio = 10.00 # Cost per million audio output tokens (USD) [limit] context = 400_000 # Maximum context window (tokens) input = 272_000 # Maximum input tokens output = 8_192 # Maximum output tokens [modalities] input = ["text", "image"] # Supported input modalities output = ["text"] # Supported output modalities [interleaved] field = "reasoning_content" # Name of the interleaved field "reasoning_content" or "reasoning_details" ``` #### 3a. Reuse Model Metadata with `base_model` 对于镜像现有模型的封装提供商(wrapper provider),优先引用仅含模型的元数据,而不是重复与提供商无关的字段。 当提供商提供相同的底层模型,且仅提供商特定字段不同时,使用 `base_model`。 ```toml base_model = "anthropic/claude-opus-4-6" [cost] input = 5.00 output = 25.00 ``` 规则: - `base_model` 必须指向 `models/` 中的 TOML 文件,使用 `