---
title: LLM API — 兼容 OpenAI | RunAPI
description: 通过一个兼容 OpenAI 的 API endpoint 访问 RunAPI 语言模型。
url: https://runapi.ai/zh-CN/llm.md
canonical: https://runapi.ai/zh-CN/llm
locale: zh-CN
site: RunAPI
image: https://runapi.ai/assets/opengraph-bfaaa0f0.png
alternates:
  en: https://runapi.ai/llm
  zh-CN: https://runapi.ai/zh-CN/llm
  es: https://runapi.ai/es/llm
  ja: https://runapi.ai/ja/llm
  de: https://runapi.ai/de/llm
  fr: https://runapi.ai/fr/llm
  pt-BR: https://runapi.ai/pt-BR/llm
  ko: https://runapi.ai/ko/llm
  it: https://runapi.ai/it/llm
  nl: https://runapi.ai/nl/llm
  pl: https://runapi.ai/pl/llm
  tr: https://runapi.ai/tr/llm
  zh-TW: https://runapi.ai/zh-TW/llm
  zh-HK: https://runapi.ai/zh-HK/llm
  ar: https://runapi.ai/ar/llm
  x-default: https://runapi.ai/llm
---

> HTML version: https://runapi.ai/zh-CN/llm
> Site index for agents: https://runapi.ai/llms.txt

<!-- llm-api-slot: api-hero-metrics owner=API-1983 state=ready -->

# LLM API — 兼容 OpenAI

通过一个兼容 OpenAI 的 endpoint 访问 [Claude](https://runapi.ai/zh-CN/models/claude.md)、GPT、[Gemini](https://runapi.ai/zh-CN/models/gemini.md)、[DeepSeek](https://runapi.ai/zh-CN/models/deepseek.md) 和 Grok。支持 /v1/chat/completions、/v1/messages、/v1/responses。

[获取 API Key](https://runapi.ai/zh-CN/login) [浏览模型](https://runapi.ai/zh-CN/models.md)

67 个模型 · 直接替换 base_url · 按 token 付费

| Value | Metric |
| --- | --- |
| 67 | LLM 模型 |
| 15-25% | 低于官方价格 |
| 2 行代码 | 迁移方式 |


<!-- llm-api-slot: llm-playground owner=API-1987 state=dependency_pending -->


<!-- llm-api-slot: multi-model-comparison owner=API-1984 state=ready -->

## 多模型对比

Prompt: `用一句话解释量子计算`

| Model | Provider | Price |
| --- | --- | --- |
| Claude/claude-fable-5 (`/v1/messages`) | Anthropic | Input $10.00 / 1M tokens \| Output $50.00 / 1M tokens |
| Claude/claude-fable-5-1 (`/v1/messages`) | Anthropic | Input $10.00 / 1M tokens \| Output $50.00 / 1M tokens |
| Claude/claude-haiku-4-5-20251001 (`/v1/messages`) | Anthropic | Input $0.60 / 1M tokens \| Output $3.00 / 1M tokens |


<!-- llm-api-slot: endpoint-shape-cards owner=API-1985 state=ready -->

## 4 种 endpoint 格式，一个 key

- **Chat completion** - 各类 SDK 通用的 OpenAI 请求格式。替换 base_url，保留现有请求代码。
- **Message** - 适用于系统提示、工具调用和结构化内容块的 Messages API 格式。
- **Response** - 适用于多轮 agent 循环、支持服务端会话管理的有状态请求格式。
- **Embedding** - 用于检索的向量 embedding，使用同一 RunAPI key 按 token 计费。


<!-- llm-api-slot: model-pricing-list owner=API-1986 state=ready -->
## 一个 key，所有 LLM

| Model | Provider | Price |
| --- | --- | --- |
| Claude/claude-fable-5 | Anthropic | $10.00 / 1M in |
| Claude/claude-fable-5-1 | Anthropic | $10.00 / 1M in |
| Claude/claude-haiku-4-5-20251001 | Anthropic | $0.60 / 1M in |
| Claude/claude-opus-4-1-20250805 | Anthropic | $9.00 / 1M in |
| Claude/claude-opus-4-5-20251101 | Anthropic | $3.00 / 1M in |
| Claude/claude-opus-4-6 | Anthropic | $3.00 / 1M in |
| Claude/claude-opus-4-7 | Anthropic | $3.00 / 1M in |
| Claude/claude-opus-4-8 | Anthropic | $3.00 / 1M in |


[查看全部 67 个 LLM 模型](https://runapi.ai/zh-CN/models.md)


<!-- llm-api-slot: quickstart-code-panel owner=API-1988 state=ready -->
## 快速入门

### 使用 OpenAI 格式调用任意模型

#### curl

```bash
curl https://runapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $RUNAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-flash","messages":[{"role":"user","content":"Explain the difference between concurrency and parallelism."}]}'
```

#### 响应

```json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 8,
    "total_tokens": 20
  }
}
```


<!-- llm-api-slot: four-step-flow owner=API-1989 state=ready -->
## 四步完成首次生成

**使用方式**

1. **获取 API Key** - 为你的 RunAPI 账户创建一个 Key。
2. **使用 OpenAI 格式** - 通过文档中的 OpenAI 兼容端点发送请求。
3. **智能路由** - RunAPI 为你的请求选择受支持的路由。
4. **流式返回** - 在所选端点支持 SSE 时接收流式输出。


<!-- llm-api-slot: benefit-cards owner=API-1990 state=ready -->

## 开发者选择 RunAPI 的理由

### 一个 Key，所有模型

无需管理多套 API 密钥。一次接入，即可访问全部 230+ 个模型。

### 节省 15-25% 成本

我们与服务商的批量协议让我们能够提供低于直接采购的价格，无任何加价。

### 自动故障转移

若某服务商出现故障，我们将自动路由至次优选项，确保您的应用持续可用。

### 兼容 OpenAI

OpenAI SDK 的直接替代方案。修改一行代码即可访问任意模型。

### 实时账单

只为实际用量付费。按请求计费，无最低消费。支持按模型、按项目追踪费用。

### 数据隐私

隐私政策说明了请求数据和生成内容的处理与保存方式。



<!-- llm-api-slot: related-api-cards owner=API-1991 state=ready -->

### 探索

## 更多 AI API

- [视频 API](https://runapi.ai/zh-CN/models.md?modality=video) - 使用 80 个模型生成、编辑和超分辨率放大视频 [了解更多](https://runapi.ai/zh-CN/models.md?modality=video)
- [图像 API](https://runapi.ai/zh-CN/models.md?modality=image) - 使用 49 个模型创作和变换图像 [了解更多](https://runapi.ai/zh-CN/models.md?modality=image)
- [音乐 API](https://runapi.ai/zh-CN/models.md?modality=audio_music) - 用 AI 创作原创音乐 [了解更多](https://runapi.ai/zh-CN/models.md?modality=audio_music)
- [音频 API](https://runapi.ai/zh-CN/models.md?modality=audio_music) - 文本转语音，支持 31 个模型 [了解更多](https://runapi.ai/zh-CN/models.md?modality=audio_music)


<!-- llm-api-slot: team-use-case-cards owner=API-1992 state=ready -->

## 团队的典型应用场景

**编程 Agent**

将规划任务路由至 Opus，将编辑任务交给低价模型，一个 key，一张账单。

**RAG 流水线**

Embedding 与生成共用同一 endpoint，检索与问答共享同一预算。

**内容生成**

将同一 prompt 分发至多个模型并保留最佳结果，无需签署五份服务商合同。

**多模型对比**

只需修改一个字符串，即可对 Claude、GPT 和 Gemini 进行同 prompt A/B 测试。



<!-- llm-api-slot: comparison-matrix owner=API-1993 state=ready -->

## RunAPI 与其他方案对比

| 功能 | RunAPI | OpenRouter | 直接调用 API |
| --- | --- | --- | --- |
| LLM 模型 | 66 | 300+ | 1 个提供商 |
| 其他模态 | 视频、图像、音乐、音频 | 否 | 按服务商 |
| 定价 | 低于官方价格 15-25% | 市场价 | 官方费率 |
| 原生 Messages API | 是 | 否 | 是 |
| 统一积分 | 是 | 是 | 否 |
| MCP server + CLI | 是 | 否 | 否 |


<!-- llm-api-slot: faq-accordion owner=API-1994 state=ready -->

## LLM API 常见问题

### 如何从兼容 OpenAI 的客户端迁移？

将客户端指向 RunAPI 文档中的 base URL，并使用您的 RunAPI key。保持所选 endpoint 支持的请求格式不变。

### 支持流式输出吗？

当所选模型和 endpoint 在其运行时协议中支持流式响应时，即可使用流式输出。

### 工具调用可用吗？

在运行时协议中声明了工具支持的模型和 endpoint 格式上，即可使用工具调用。

### token 如何计费？

输入和输出费率已在模型目录中列出。费用根据请求上报的 token 用量计算。

### 应该使用哪个 endpoint？

选择与您现有客户端匹配、且满足请求所需功能的 endpoint 格式。

### 如果某个路由不可用怎么办？

API 会通过其文档化的响应协议返回请求状态，您的应用可据此进行重试或切换到其他支持的模型。



<!-- llm-api-slot: final-cta owner=API-1995 state=ready -->
## 修改两行代码，保留其余代码

您已在使用的 OpenAI 格式背后有 67 个模型可供调用。免费开始，无需信用卡。

- [获取 API Key](https://runapi.ai/zh-CN/login)
- [阅读文档](https://runapi.ai/zh-CN/docs/guides)




---

## More from RunAPI

- [Home](https://runapi.ai/zh-CN/.md)
### 产品
- [模型目录](https://runapi.ai/zh-CN/models.md)
- [定价](https://runapi.ai/zh-CN/pricing.md)
- [提供方](https://runapi.ai/zh-CN/models#all-models)
### 开发者
- [文档](https://runapi.ai/zh-CN/docs/guides)
- [SDK](https://runapi.ai/zh-CN/sdk.md)
- [CLI](https://runapi.ai/zh-CN/cli.md)
- [MCP Server](https://runapi.ai/zh-CN/mcp.md)
### 指南
- [Claude Code 与 Cursor](https://runapi.ai/zh-CN/claude-code-vs-cursor.md)
- [Cursor API 设置](https://runapi.ai/zh-CN/cursor-api-setup.md)
- [RunAPI 与 OpenRouter](https://runapi.ai/zh-CN/openrouter-alternative.md)
### 公司
- [企业版](https://runapi.ai/zh-CN/contact.md)
- [联系](https://runapi.ai/zh-CN/contact.md)
### 法律
- [服务条款](https://runapi.ai/zh-CN/terms.md)
- [隐私政策](https://runapi.ai/zh-CN/privacy.md)
- [Site index for agents](https://runapi.ai/llms.txt)

Contact: contact@runapi.ai

## Structured data

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/zh-CN/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "zh-CN",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/zh-CN",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/zh-CNicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  }
]
```
