Skip to main content
POST
/
chat
/
chat
/
completions
聊天完成 (OpenAI 兼容)
curl --request POST \
  --url https://api.mountsea.ai/chat/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-5.1",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "stream": false,
  "temperature": 1,
  "max_tokens": 1000,
  "max_completion_tokens": 1000,
  "top_p": 1,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "stop": {},
  "n": 1,
  "seed": 12345,
  "user": "<string>",
  "tools": [
    {}
  ],
  "tool_choice": {},
  "response_format": {},
  "logprobs": false,
  "top_logprobs": 5,
  "logit_bias": {},
  "parallel_tool_calls": true
}
'

💡 Quick Examples

from openai import OpenAI

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

# Basic 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)
Streaming:
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="")

📤 Response Format

Non-streaming Response

{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "gpt-5.1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 26,
    "completion_tokens": 10,
    "total_tokens": 36
  }
}

Streaming Response (SSE)

data: {"id":"chatcmpl-xxx","choices":[{"delta":{"role":"assistant"}}]}

data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"Hello"}}]}

data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"!"}}]}

data: {"id":"chatcmpl-xxx","choices":[{"delta":{},"finish_reason":"stop"}]}

data: [DONE]

🔧 API Reference

The interactive API form below is auto-generated from OpenAPI spec. All available models are shown in the model dropdown.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
enum<string>
required

模型名称

Available options:
gpt-5.1,
gpt-5.1-all,
gpt-5.1-thinking,
gpt-5.1-thinking-all,
gpt-5.2,
gemini-3-pro,
gemini-2.5-pro,
gemini-2.5-flash,
gemini-3-flash,
claude-4.5
Example:

"gpt-5.1"

messages
object[]
required

消息列表

Example:
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{ "role": "user", "content": "Hello!" }
]
stream
boolean

是否流式输出

Example:

false

temperature
number | null

温度 (0-2)

Example:

1

max_tokens
number | null

最大 token 数

Example:

1000

max_completion_tokens
number | null

最大补全 token 数 (新版参数)

Example:

1000

top_p
number | null

Top P

Example:

1

frequency_penalty
number | null

频率惩罚 (-2.0 到 2.0)

Example:

0

presence_penalty
number | null

存在惩罚 (-2.0 到 2.0)

Example:

0

stop
object

停止序列

n
number | null

生成数量

Example:

1

seed
number | null

随机种子

Example:

12345

user
string

用户标识

tools
object[]

工具列表 (Function Calling)

tool_choice
object

工具选择策略

response_format
object

响应格式

logprobs
boolean | null

是否返回 logprobs

Example:

false

top_logprobs
number | null

top logprobs 数量

Example:

5

logit_bias
object

logit 偏置

parallel_tool_calls
boolean

并行工具调用

Example:

true

Response

成功