Appearance
GPT 模型接口文档
兼容 OpenAI Chat Completions 接口,支持 GPT 系列模型的普通消息、流式输出与工具调用。
Base URL:https://agentpivot.ai/
登录平台
- Url:https://agentpivot.ai/
- token:平台创建
- api-key: 平台创建
接口概览
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /v1/chat/completions | 统一消息接口(普通 / 流式 / 工具调用) |
鉴权
二选一,任选一种即可:
| Header | 说明 |
|---|---|
x-api-key: <API_KEY> | 使用 API Key |
Authorization: Bearer <token> | 使用 JWT 或 Bearer Token |
示例:
bash
curl -X POST "https://api.agentpivot.ai/v1/chat/completions" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [{"role": "user", "content": "Hello, how are you?"}],
"max_tokens": 1024,
"temperature": 0.7
}'POST /v1/chat/completions
请求
- Content-Type:
application/json - Body:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型标识,如 gpt-5.4、gpt-4o、gpt-4.1 |
messages | array | 是 | 对话消息列表,每项含 role(system/user/assistant)、content(字符串) |
max_tokens | number | 否 | 回复最大 token 数 |
temperature | number | 否 | 采样温度,范围 0~2,默认 1 |
top_p | number | 否 | 核采样概率,范围 0~1,默认 1 |
stream | boolean | 否 | 为 true 时返回 SSE 流式 响应 |
tools | array | 否 | 工具定义列表,有且 length > 0 时走 工具调用 |
tool_choice | string/object | 否 | 工具选择策略,如 auto、none、required |
messages 单项结构:
| 字段 | 类型 | 说明 |
|---|---|---|
role | string | system | user | assistant | tool |
content | string | 消息内容 |
tools 单项结构(工具调用时):
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 function |
function.name | string | 函数名称,如 get_weather |
function.description | string | 函数描述 |
function.parameters | object | 参数 JSON Schema:type: "object",properties,required |
行为说明
- 流式:当
stream === true时,响应为 SSE(Content-Type: text/event-stream),每行以data:开头,最终以data: [DONE]结束。 - 工具调用:当
tools存在且长度 > 0 时,模型可能返回tool_calls,需将工具执行结果作为role: tool消息追加后继续请求。 - 普通消息:其余情况为普通对话,支持
max_tokens、temperature等参数,响应为 JSON。
响应
普通消息(JSON)
json
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1700000000,
"model": "gpt-5.4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I'm doing well, thank you!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 10,
"total_tokens": 22
}
}| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 请求 ID |
object | string | 固定为 chat.completion |
choices | array | 回复列表,通常只有一项 |
choices[].message.role | string | 角色,固定为 assistant |
choices[].message.content | string | 回复内容 |
choices[].finish_reason | string | 结束原因:stop / length / tool_calls |
usage.prompt_tokens | number | 输入 token 数 |
usage.completion_tokens | number | 输出 token 数 |
流式(SSE)
- Content-Type:
text/event-stream - 每行格式:
data: {"id":"...","object":"chat.completion.chunk","choices":[{"delta":{"content":"..."},"index":0}]} - 结束标志:
data: [DONE]
工具调用
模型返回 finish_reason: "tool_calls" 时,message.tool_calls 包含调用信息:
json
{
"choices": [{
"message": {
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_xxx",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"北京\"}"
}
}]
},
"finish_reason": "tool_calls"
}]
}模型列表
GPT-3.5 系列
| 模型名称 |
|---|
| gpt-3.5-turbo |
| gpt-3.5-turbo-0125 |
| gpt-3.5-turbo-1106 |
| gpt-3.5-turbo-16k |
| gpt-3.5-turbo-16k-0613 |
GPT-4 系列
| 模型名称 |
|---|
| gpt-4 |
| gpt-4-0613 |
| gpt-4-32k |
| gpt-4-32k-0613 |
| gpt-4-turbo |
| gpt-4-turbo-preview |
| gpt-4-turbo-2024-04-09 |
| gpt-4-0125-preview |
| gpt-4-1106-preview |
GPT-4o 系列
| 模型名称 |
|---|
| gpt-4o |
| gpt-4o-2024-05-13 |
| gpt-4o-2024-08-06 |
| gpt-4o-2024-11-20 |
| gpt-4o-mini |
| gpt-4o-mini-2024-07-18 |
| gpt-4o-mini-tts |
| gpt-4o-realtime-preview |
| gpt-4o-realtime-preview-2024-12-17 |
| gpt-4o-transcribe |
| gpt-4o-transcribe-diarize |
GPT-4.1 系列
| 模型名称 |
|---|
| gpt-4.1 |
| gpt-4.1-2025-04-14 |
| gpt-4.1-mini |
| gpt-4.1-mini-2025-04-14 |
| gpt-4.1-nano |
| gpt-4.1-nano-2025-04-14 |
GPT-5 系列
| 模型名称 |
|---|
| gpt-5 |
| gpt-5-2025-08-07 |
| gpt-5-chat |
| gpt-5-chat-2025-08-07 |
| gpt-5-chat-latest |
| gpt-5-codex |
| gpt-5-mini |
| gpt-5-mini-2025-08-07 |
| gpt-5-nano |
| gpt-5-nano-2025-08-07 |
GPT-5.1 系列
| 模型名称 |
|---|
| gpt-5.1 |
| gpt-5.1-2025-11-13 |
| gpt-5.1-chat |
| gpt-5.1-chat-2025-11-13 |
| gpt-5.1-chat-latest |
| gpt-5.1-codex-max |
GPT-5.2 系列
| 模型名称 |
|---|
| gpt-5.2 |
| gpt-5.2-2025-12-11 |
| gpt-5.2-chat |
| gpt-5.2-chat-latest |
| gpt-5.2-chat-2025-12-11 |
GPT-5.3 系列
| 模型名称 |
|---|
| gpt-5.3-codex |
| gpt-5.3-chat |
| gpt-5.3-chat-latest |
| gpt-5.3-chat-2026-03-03 |
GPT-5.4 系列
| 模型名称 |
|---|
| gpt-5.4 |
| gpt-5.4-2026-03-05 |
| gpt-5.4-mini |
| gpt-5.4-nano |
| gpt-5.4-pro |
GPT 扩展能力模型
| 模型名称 | 说明 |
|---|---|
| gpt-image-1 | 图像生成 |
| gpt-image-1.5 | 图像生成 |
| gpt-realtime | 实时语音 |
| gpt-realtime-2025-08-28 | 实时语音 |
| gpt-oss-120b | 开源大模型 |
请求示例
1. 普通消息
json
{
"model": "gpt-5.4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, how are you?"}
],
"max_tokens": 1024,
"temperature": 0.7
}2. 流式
json
{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "用一句话介绍自己"}
],
"stream": true
}流式 curl 示例:
bash
curl -X POST "https://api.agentpivot.ai/v1/chat/completions" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'3. 工具调用
json
{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "今天北京的天气怎么样?"}
],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取指定城市的当前天气",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "城市名称,如:北京"}
},
"required": ["location"]
}
}
}],
"tool_choice": "auto"
}4. 多轮对话
json
{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "你是一个专业的助手。"},
{"role": "user", "content": "什么是机器学习?"},
{"role": "assistant", "content": "机器学习是人工智能的一个分支..."},
{"role": "user", "content": "能举个例子吗?"}
]
}5. 图像生成(gpt-image-1)
bash
curl -X POST "https://api.agentpivot.ai/v1/chat/completions" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"messages": [
{"role": "user", "content": "画一只在草地上奔跑的金毛犬"}
]
}'测试脚本
bash
export API_KEY="YOUR_API_KEY"
curl -X POST "https://api.agentpivot.ai/v1/chat/completions" \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [{"role": "user", "content": "Hello, how are you?"}],
"max_tokens": 1024,
"temperature": 0.7
}'