> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mountsea.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

# Chat 简介

欢迎使用 **Chat** 服务文档！

本服务提供多协议 AI API 网关，支持 **OpenAI 兼容 API**、**OpenAI Responses API**、**Anthropic (Claude) 兼容 API** 和 **Google Gemini 原生 API**。您可以使用官方 SDK 或任何兼容客户端（如 **Cherry Studio**、**Claude Code**、**Cursor** 等）来访问我们强大的语言模型。

## 🌟 核心特性

### 多协议支持

我们的 Chat API 支持多种 API 格式以满足不同需求：

| 协议                     | Base URL                              | 描述                                       |
| ---------------------- | ------------------------------------- | ---------------------------------------- |
| **OpenAI 兼容**          | `https://api.mountsea.ai/chat`        | 兼容 OpenAI Chat Completions API           |
| **OpenAI Responses**   | `https://api.mountsea.ai/chat`        | 兼容 OpenAI Responses API 格式               |
| **Anthropic (Claude)** | `https://api.mountsea.ai/chat/claude` | 兼容 Anthropic Messages API，支持 Claude Code |
| **Gemini 原生**          | `https://api.mountsea.ai/chat/gemini` | 兼容 Google Gemini Native API              |

<Warning>
  **注意 Base URL 区别**：Claude Code 使用的 Base URL 为 `https://api.mountsea.ai/chat/claude`，其他协议统一使用 `https://api.mountsea.ai/chat`。
</Warning>

### OpenAI 兼容

* ✅ 直接使用**官方 OpenAI Python/Node.js SDK**
* ✅ 无需修改代码 - 只需更新 `base_url` 和 `api_key`
* ✅ 完整支持**流式响应**
* ✅ 支持 **Function Calling / Tools**
* ✅ 支持 **JSON Mode** 和结构化输出

### OpenAI Responses API

* ✅ 支持全新 **OpenAI Responses API** 格式（`/v1/responses`）
* ✅ 兼容 **Cherry Studio** 和其他使用 Responses API 的客户端
* ✅ 简化的输入格式，使用 `input` 和 `instructions`

### Anthropic (Claude Code) 兼容

* ✅ 直接使用 **Claude Code** CLI 接入我们的服务
* ✅ 兼容 **Anthropic Python/TypeScript SDK**
* ✅ 完整支持**流式响应**、**工具调用**和**系统提示**
* ✅ 访问 Claude 模型（claude-4.5、claude-opus-4-6、claude-sonnet-4-6 等）

### 支持的模型

我们提供多种高质量语言模型的访问：

| 模型                          | 类型        | 描述                          |
| --------------------------- | --------- | --------------------------- |
| `gpt-5.1`                   | OpenAI    | 最新 GPT-5.1 模型               |
| `gpt-5.1-all`               | OpenAI    | GPT-5.1 全能力版本               |
| `gpt-5.1-thinking`          | OpenAI    | GPT-5.1 增强推理版               |
| `gpt-5.1-thinking-all`      | OpenAI    | GPT-5.1 推理全能力版              |
| `gpt-5.1-2025-11-13`        | OpenAI    | GPT-5.1 快照版（2025-11-13）     |
| `gpt-5.2`                   | OpenAI    | 最新 GPT-5.2 模型               |
| `gemini-3-pro`              | Google    | Google Gemini 3 Pro         |
| `gemini-2.5-pro`            | Google    | Google Gemini 2.5 Pro       |
| `gemini-2.5-flash`          | Google    | Google Gemini 2.5 Flash（更快） |
| `gemini-3-flash`            | Google    | Google Gemini 3 Flash（更快）   |
| `gemini-3.1-pro`            | Google    | Google Gemini 3.1 Pro       |
| `claude-4.5`                | Anthropic | Claude 4.5 模型               |
| `claude-opus-4-6`           | Anthropic | Claude Opus 4.6 模型          |
| `claude-sonnet-4-6`         | Anthropic | Claude Sonnet 4.6 模型        |
| `claude-haiku-4-5-20251001` | Anthropic | Claude Haiku 4.5（轻量快速）      |

***

## 🚀 快速开始

### 使用 OpenAI Python SDK

```python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.mountsea.ai/chat"
)

response = client.chat.completions.create(
    model="gpt-5.1",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)
```

### 使用 OpenAI Node.js SDK

```javascript theme={null}
import OpenAI from 'openai';

const client = new OpenAI({
    apiKey: 'your-api-key',
    baseURL: 'https://api.mountsea.ai/chat'
});

const response = await client.chat.completions.create({
    model: 'gpt-5.1',
    messages: [
        { role: 'system', content: 'You are a helpful assistant.' },
        { role: 'user', content: 'Hello!' }
    ]
});

console.log(response.choices[0].message.content);
```

### 流式响应

```python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="your-api-key",
    base_url="https://api.mountsea.ai/chat"
)

stream = client.chat.completions.create(
    model="gpt-5.1",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
```

### 使用 cURL

```bash theme={null}
curl https://api.mountsea.ai/chat/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{
    "model": "gpt-5.1",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ]
  }'
```

***

## 🤖 Claude Code 接入指南

[Claude Code](https://docs.anthropic.com/en/docs/claude-code) 是 Anthropic 官方的 AI 编程 CLI 工具。通过配置我们的 API，你可以直接使用 Claude Code 进行 AI 辅助编程。

<Info>
  Claude Code 使用 Anthropic Messages API 格式，Base URL 为 **`https://api.mountsea.ai/chat/claude`**，与其他协议不同，请注意区分。
</Info>

### 配置方法

设置环境变量即可使用：

<Tabs>
  <Tab title="macOS / Linux">
    ```bash theme={null}
    # 设置 API Key 和 Base URL
    export ANTHROPIC_API_KEY="your-api-key"
    export ANTHROPIC_BASE_URL="https://api.mountsea.ai/chat/claude"

    # 启动 Claude Code
    claude
    ```

    **持久化配置（添加到 \~/.bashrc 或 \~/.zshrc）：**

    ```bash theme={null}
    echo 'export ANTHROPIC_API_KEY="your-api-key"' >> ~/.zshrc
    echo 'export ANTHROPIC_BASE_URL="https://api.mountsea.ai/chat/claude"' >> ~/.zshrc
    source ~/.zshrc
    ```
  </Tab>

  <Tab title="Windows (PowerShell)">
    ```powershell theme={null}
    # 设置环境变量
    $env:ANTHROPIC_API_KEY = "your-api-key"
    $env:ANTHROPIC_BASE_URL = "https://api.mountsea.ai/chat/claude"

    # 启动 Claude Code
    claude
    ```

    **持久化配置：**

    ```powershell theme={null}
    [System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "your-api-key", "User")
    [System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.mountsea.ai/chat/claude", "User")
    ```
  </Tab>

  <Tab title="Windows (CMD)">
    ```cmd theme={null}
    :: 设置环境变量
    set ANTHROPIC_API_KEY=your-api-key
    set ANTHROPIC_BASE_URL=https://api.mountsea.ai/chat/claude

    :: 启动 Claude Code
    claude
    ```
  </Tab>
</Tabs>

### 使用 Anthropic SDK 调用

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import anthropic

    client = anthropic.Anthropic(
        api_key="your-api-key",
        base_url="https://api.mountsea.ai/chat/claude"
    )

    message = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=4096,
        system="You are a helpful coding assistant.",
        messages=[
            {"role": "user", "content": "Write a Python function to sort a list"}
        ]
    )

    print(message.content[0].text)
    ```

    **流式响应：**

    ```python theme={null}
    with client.messages.stream(
        model="claude-sonnet-4-6",
        max_tokens=4096,
        messages=[{"role": "user", "content": "Explain async/await in Python"}]
    ) as stream:
        for text in stream.text_stream:
            print(text, end="")
    ```

    **安装：**

    ```bash theme={null}
    pip install anthropic
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    import Anthropic from '@anthropic-ai/sdk';

    const client = new Anthropic({
        apiKey: 'your-api-key',
        baseURL: 'https://api.mountsea.ai/chat/claude'
    });

    const message = await client.messages.create({
        model: 'claude-sonnet-4-6',
        max_tokens: 4096,
        system: 'You are a helpful coding assistant.',
        messages: [
            { role: 'user', content: 'Write a TypeScript function to sort an array' }
        ]
    });

    console.log(message.content[0].text);
    ```

    **流式响应：**

    ```javascript theme={null}
    const stream = await client.messages.stream({
        model: 'claude-sonnet-4-6',
        max_tokens: 4096,
        messages: [{ role: 'user', content: 'Explain async/await in JavaScript' }]
    });

    for await (const event of stream) {
        if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
            process.stdout.write(event.delta.text);
        }
    }
    ```

    **安装：**

    ```bash theme={null}
    npm install @anthropic-ai/sdk
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://api.mountsea.ai/chat/claude/v1/messages \
      -H "Content-Type: application/json" \
      -H "x-api-key: your-api-key" \
      -H "anthropic-version: 2023-06-01" \
      -d '{
        "model": "claude-sonnet-4-6",
        "max_tokens": 4096,
        "system": "You are a helpful assistant.",
        "messages": [
          {"role": "user", "content": "Hello, Claude!"}
        ]
      }'
    ```
  </Tab>
</Tabs>

***

## 📱 Cherry Studio 接入指南

[Cherry Studio](https://cherry-ai.com) 是一款功能强大的 AI 桌面客户端，支持多种 API 格式。你可以通过配置我们的 API 在 Cherry Studio 中使用所有模型。

### 配置 OpenAI 兼容模式（推荐）

<Steps>
  <Step title="打开设置">
    在 Cherry Studio 中，进入 **设置** → **模型服务商** → 点击 **添加**
  </Step>

  <Step title="配置 API">
    填写以下信息：

    | 配置项     | 值                              |
    | ------- | ------------------------------ |
    | 服务商名称   | `MountSea AI`                  |
    | API 地址  | `https://api.mountsea.ai/chat` |
    | API Key | 你的 API Key                     |
  </Step>

  <Step title="添加模型">
    点击 **添加模型**，手动输入模型名称，例如：`gpt-5.1`、`claude-sonnet-4-6`、`gemini-3-flash` 等
  </Step>

  <Step title="开始对话">
    在对话界面选择对应模型，即可开始使用
  </Step>
</Steps>

### 配置 OpenAI Responses 模式

如果 Cherry Studio 使用 OpenAI Responses API 格式，配置方式相同：

| 配置项     | 值                              |
| ------- | ------------------------------ |
| API 地址  | `https://api.mountsea.ai/chat` |
| API Key | 你的 API Key                     |
| API 格式  | OpenAI Responses               |

***

## 📋 可用端点

### OpenAI 兼容 API

| 端点                          | 方法   | 描述         |
| --------------------------- | ---- | ---------- |
| `/chat/chat/completions`    | POST | 创建聊天补全     |
| `/chat/v1/chat/completions` | POST | 创建聊天补全（v1） |
| `/chat/models`              | GET  | 列出可用模型     |
| `/chat/models/{model}`      | GET  | 获取模型详情     |

### OpenAI Responses API

| 端点                   | 方法   | 描述                     |
| -------------------- | ---- | ---------------------- |
| `/chat/v1/responses` | POST | 创建响应（Responses API 格式） |

### Anthropic 兼容 API (Claude Code)

<Warning>
  Base URL: `https://api.mountsea.ai/chat/claude`（注意与其他 API 不同）
</Warning>

| 端点                         | 方法   | 描述                 |
| -------------------------- | ---- | ------------------ |
| `/chat/claude/v1/messages` | POST | 创建消息（Anthropic 格式） |

### Gemini 原生 API

| 端点                                                               | 方法   | 描述        |
| ---------------------------------------------------------------- | ---- | --------- |
| `/chat/gemini/{apiVersion}/models/{model}:generateContent`       | POST | 生成内容（非流式） |
| `/chat/gemini/{apiVersion}/models/{model}:streamGenerateContent` | POST | 生成内容（流式）  |

<Tip>
  Gemini 原生 API 允许您直接使用官方 `@google/genai` SDK。详见 [Gemini API](gemini)。
</Tip>

***

### 浏览 API 文档

**OpenAI 兼容：**

* [Chat Completions](completions) - 创建聊天补全
* [列出模型](models) - 获取可用模型
* [获取模型](model) - 获取特定模型信息

**OpenAI Responses API：**

* [Responses API](responses) - 使用 OpenAI Responses 格式创建响应

**Anthropic 兼容 (Claude Code)：**

* [Claude Messages API](claude) - 使用 Claude Code 或 Anthropic SDK

**Gemini 原生：**

* [Gemini API](gemini) - 使用原生 Google Gemini SDK

***

更多详情，请访问完整的 [MountSea API 文档](https://docs.mountsea.ai)。
