聊天完成 (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
}
'import requests
url = "https://api.mountsea.ai/chat/chat/completions"
payload = {
"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
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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
})
};
fetch('https://api.mountsea.ai/chat/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mountsea.ai/chat/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mountsea.ai/chat/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-5.1\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": false,\n \"temperature\": 1,\n \"max_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"top_p\": 1,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"stop\": {},\n \"n\": 1,\n \"seed\": 12345,\n \"user\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"logprobs\": false,\n \"top_logprobs\": 5,\n \"logit_bias\": {},\n \"parallel_tool_calls\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mountsea.ai/chat/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-5.1\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": false,\n \"temperature\": 1,\n \"max_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"top_p\": 1,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"stop\": {},\n \"n\": 1,\n \"seed\": 12345,\n \"user\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"logprobs\": false,\n \"top_logprobs\": 5,\n \"logit_bias\": {},\n \"parallel_tool_calls\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mountsea.ai/chat/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-5.1\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": false,\n \"temperature\": 1,\n \"max_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"top_p\": 1,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"stop\": {},\n \"n\": 1,\n \"seed\": 12345,\n \"user\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"logprobs\": false,\n \"top_logprobs\": 5,\n \"logit_bias\": {},\n \"parallel_tool_calls\": true\n}"
response = http.request(request)
puts response.read_bodyChat
Chat Completions
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
}
'import requests
url = "https://api.mountsea.ai/chat/chat/completions"
payload = {
"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
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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
})
};
fetch('https://api.mountsea.ai/chat/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mountsea.ai/chat/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mountsea.ai/chat/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-5.1\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": false,\n \"temperature\": 1,\n \"max_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"top_p\": 1,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"stop\": {},\n \"n\": 1,\n \"seed\": 12345,\n \"user\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"logprobs\": false,\n \"top_logprobs\": 5,\n \"logit_bias\": {},\n \"parallel_tool_calls\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mountsea.ai/chat/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-5.1\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": false,\n \"temperature\": 1,\n \"max_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"top_p\": 1,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"stop\": {},\n \"n\": 1,\n \"seed\": 12345,\n \"user\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"logprobs\": false,\n \"top_logprobs\": 5,\n \"logit_bias\": {},\n \"parallel_tool_calls\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mountsea.ai/chat/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-5.1\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": false,\n \"temperature\": 1,\n \"max_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"top_p\": 1,\n \"frequency_penalty\": 0,\n \"presence_penalty\": 0,\n \"stop\": {},\n \"n\": 1,\n \"seed\": 12345,\n \"user\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"response_format\": {},\n \"logprobs\": false,\n \"top_logprobs\": 5,\n \"logit_bias\": {},\n \"parallel_tool_calls\": true\n}"
response = http.request(request)
puts response.read_body💡 Quick Examples
- Python
- Node.js
- Java
- Go
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)
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="")
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'your-api-key',
baseURL: 'https://api.mountsea.ai/chat'
});
// Basic 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);
const stream = await client.chat.completions.create({
model: 'gpt-5.1',
messages: [{ role: 'user', content: 'Tell me a story' }],
stream: true
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.*;
// Initialize client
OpenAIClient client = OpenAIOkHttpClient.builder()
.apiKey("your-api-key")
.baseUrl("https://api.mountsea.ai/chat")
.build();
// Basic chat
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.model("gpt-5.1")
.addMessage(ChatCompletionMessageParam.ofSystem(
SystemMessage.builder().content("You are a helpful assistant.").build()))
.addMessage(ChatCompletionMessageParam.ofUser(
UserMessage.builder().content("Hello!").build()))
.build();
ChatCompletion response = client.chat().completions().create(params);
System.out.println(response.choices().get(0).message().content());
ChatCompletionCreateParams streamParams = ChatCompletionCreateParams.builder()
.model("gpt-5.1")
.addMessage(ChatCompletionMessageParam.ofUser(
UserMessage.builder().content("Tell me a story").build()))
.build();
client.chat().completions().createStreaming(streamParams)
.forEach(chunk -> {
String content = chunk.choices().get(0).delta().content().orElse("");
System.out.print(content);
});
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>0.8.0</version>
</dependency>
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
// Initialize client
client := openai.NewClient(
option.WithAPIKey("your-api-key"),
option.WithBaseURL("https://api.mountsea.ai/chat"),
)
// Basic chat
response, _ := client.Chat.Completions.New(context.TODO(),
openai.ChatCompletionNewParams{
Model: openai.String("gpt-5.1"),
Messages: []openai.ChatCompletionMessageParamUnion{
openai.SystemMessage("You are a helpful assistant."),
openai.UserMessage("Hello!"),
},
},
)
fmt.Println(response.Choices[0].Message.Content)
}
stream := client.Chat.Completions.NewStreaming(context.TODO(),
openai.ChatCompletionNewParams{
Model: openai.String("gpt-5.1"),
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage("Tell me a story"),
},
},
)
for stream.Next() {
chunk := stream.Current()
fmt.Print(chunk.Choices[0].Delta.Content)
}
go get github.com/openai/openai-go
📤 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
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
模型名称
Available options:
gpt-5.1, gpt-5.1-all, gpt-5.1-thinking, gpt-5.1-thinking-all, gpt-5.2, gpt-5.3, gpt-5.3-codex, gpt-5.4, gemini-3-pro, gemini-2.5-pro, gemini-2.5-flash, gemini-3-flash, gemini-3.1-pro, claude-4.5, claude-opus-4-6, claude-haiku-4-5-20251001, claude-sonnet-4-6, claude-opus-4-7 Example:
"gpt-5.1"
消息列表
Example:
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{ "role": "user", "content": "Hello!" }
]
是否流式输出
Example:
false
温度 (0-2)
Example:
1
最大 token 数
Example:
1000
最大补全 token 数 (新版参数)
Example:
1000
Top P
Example:
1
频率惩罚 (-2.0 到 2.0)
Example:
0
存在惩罚 (-2.0 到 2.0)
Example:
0
停止序列
生成数量
Example:
1
随机种子
Example:
12345
用户标识
工具列表 (Function Calling)
工具选择策略
响应格式
是否返回 logprobs
Example:
false
top logprobs 数量
Example:
5
logit 偏置
并行工具调用
Example:
true
Response
200
成功
⌘I