基础信息
-
基础URL :https://genaiapi.cloudsway.net
-
API请求端点 :
POST -
身份验证 :通过HTTP Bearer Token方式验证,需要在请求头中携带API密钥。
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
Content-Type |
string | 是 | 固定为 application/json |
Authorization |
string | 是 | Bearer {your_api_key} |
核心参数说明
Openai 官方Chat Completions API文档
请求参数
| 字段 | 含义 | 层级 | 格式 | 必需 | 备注 |
|---|---|---|---|---|---|
| messages | 构成当前对话的消息列表 | 1 | arrary | 是 | 根据使用的模型不同,支持不同类型的消息内容(模态),包括文本、图像和音频 |
| Developer message | 开发者提供的指令,模型应始终遵循,无论用户发送何种消息 | 2 | object | 对于o1及更新版本的模型,开发者消息替代了之前的系统消息 | |
| content | 开发者消息的内容 | 3 | string 或者 arrary | 是 | |
| Text content | 开发者消息的内容 | 4 | string | ||
| Array of content parts | 由特定类型定义的内容块数组 | 4 | array | 对于开发者消息,仅支持文本类型(text) | |
| text | 文本内容 | 5 | string | 是 | |
| type | 内容块的类型 | 5 | string | 是 | |
| role | 消息作者的角色 | 3 | string | 是 | 此处为developer |
| name | 参与者的可选名称。用于向模型提供信息以区分相同角色的不同参与者 | 3 | string | ||
| System message | 开发者提供的指令,无论用户发送什么消息,模型都应遵循这些指令 | 2 | object | 在 o1 及更高版本的模型中,请改用开发者消息 (developer messages) 实现此功能 | |
| content | 系统消息的内容 | 3 | string 或者 arrary | 是 | |
| Text content | 系统消息的内容 | 4 | string | ||
| Array of content parts | 由特定类型定义的内容块数组 | 4 | array | 对于系统消息,仅支持文本类型(text) | |
| Text content part | 文本内容 | 5 | object | ||
| text | 文本内容 | 6 | string | 是 | |
| type | 内容块的类型 | 6 | string | 是 | |
| role | 消息作者的角色 | 3 | string | 是 | 此处为system |
| name | 参与者的可选名称。用于向模型提供信息以区分相同角色的不同参与者 | 3 | string | ||
| User message | 终端用户发送的消息,包含提示词或额外的上下文信息 | 2 | object | ||
| content | 用户消息的内容 | 3 | string 或者 arrary | 是 | |
| Text content | 用户消息的内容 | 4 | string | ||
| Array of content parts | 由特定类型定义的内容块数组 | 4 | array | 支持的内容类型根据用于生成响应的模型而有所不同,可包含文本、图像或音频输入 | |
| Text content part | 文本内容 | 5 | object | ||
| text | 文本内容 | 6 | string | 是 | |
| type | 内容块的类型 | 6 | string | 是 | |
| Image content part | 5 | object | |||
| imageurl | 6 | object | 是 | ||
| url | 图像的URL或base64编码的图像数据 | 7 | stirng | 是 | |
| detail | 指定图像的细节级别 | 7 | stirng | 默认为auto | |
| type | 内容块的类型 | 6 | string | 是 | |
| role | 消息作者的角色 | 3 | string | 是 | 此处为user |
| name | 参与者的可选名称。用于向模型提供信息以区分相同角色的不同参与者 | 3 | string | ||
| Assistant message | 模型为响应用户消息而发送的消息 | 2 | object | ||
| role | 消息作者的角色 | 3 | string | 是 | 此处为助手 assistant |
| audio | 模型先前音频响应的相关数据 | 3 | object或者null | ||
| id | 模型先前音频响应的唯一标识符 | 4 | string | 是 | |
| content | 助手消息的内容 | 3 | string 或者 arrary | 除非指定了 toolcalls 或 functioncall,否则为必需字段 | |
| Text content | 助手消息的文本内容 | 4 | string | ||
| Array of content parts | 具有定义类型的内容块数组 | 4 | array | 可包含一个或多个文本类型 (text) 内容块,或恰好一个拒绝类型 (refusal) 内容块 | |
| Text content part | 5 | object | |||
| text | 文本内容 | 6 | string | 是 | |
| type | 内容块的类型 | 6 | string | 是 | |
| Refusal content part | 5 | object | |||
| refusal | 模型生成的拒绝消息 | 6 | string | 是 | |
| type | 内容块的类型 | 6 | string | 是 | |
| functioncall | 已弃用,由 toolcalls 替代 | 3 | object或者null | 包含模型生成的应调用函数的名称和参数 | |
| name | 要调用的函数名称 | 4 | string | 是 | |
| arguments | 调用函数时使用的参数,由模型以JSON格式生成。 | 4 | string | 是 | 注意:模型生成的JSON不一定有效,可能会产生函数模式中未定义的参数。调用函数前请验证参数 |
| name | 参与者的可选名称。用于区分相同角色的不同参与者 | 3 | string | ||
| refusal | 助手的拒绝消息 | 3 | string或者null | ||
| toolcalls | 模型生成的工具调用(如函数调用) | 3 | array | ||
| Function tool call | 对模型创建的函数工具的调用 | 4 | object | ||
| function | 模型调用的函数 | 5 | object | 是 | |
| arguments | 调用函数时所需的参数,由模型以JSON格式生成 | 6 | string | 是 | 请注意,模型生成的内容并不总是有效的JSON,而且可能会虚构出函数 schema 中未定义的参数。因此,在调用函数之前,请在代码中对这些参数进行验证 |
| name | 要调用的函数名称 | 6 | string | 是 | |
| id | toolcall的ID | 5 | string | 是 | |
| type | tool的类型,目前只支持function | 5 | string | 是 | |
| Tool message | 2 | object | |||
| content | 工具消息的内容 | 3 | string或者array | 是 | |
| Text content | 工具消息的文本内容 | 4 | string | ||
| Array of content parts | 具有特定类型的内容块数组。对于工具消息,仅支持文本类型 (text) | 4 | array | ||
| Text content part | 5 | object | |||
| text | 文本内容 | 6 | string | 是 | |
| type | 内容块类型 | 6 | string | 是 | |
| role | 消息作者的角色,此处为tool | 3 | string | 是 | |
| toolcallid | 该消息所响应的工具调用ID | 3 | string | 是 | |
| model | 用于生成响应的模型ID,例如 gpt-4o 或 o3 | 1 | string | 是 | |
| frequencypenalty | 介于 -2.0 和 2.0 之间的数值,默认是0 | 1 | number或者null | 正值会根据标记在当前文本中的现有频率进行惩罚,从而降低模型逐字重复相同内容的可能性 | |
| logitbias | 调整指定标记在生成结果中出现的概率,默认为null | 1 | map | 接收一个JSON对象,该对象将标记(通过分词器中的标记ID指定)映射到-100至100之间的偏差值 数学原理:该偏差值会在模型生成logits后、采样前被加入 具体效果因模型而异,但通常:- -1到1之间的值会略微降低/提高选中概率- -100或100等极值会导致完全禁止/强制选中该标记 | |
| maxcompletiontokens | 生成结果中允许的最大标记数上限(包括可见输出标记和推理标记) | 1 | integer或者null | ||
| n | 为每条输入消息生成的聊天补全选项数量,默认为1 | 1 | integer或者null | 注意:费用将基于所有选项生成的标记总数计算,建议保持 n=1 以控制成本 | |
| paralleltoolcalls | 是否在工具使用时启用并行函数调用功能,默认为true | 1 | boolean | ||
| presencepenalty | 介于 -2.0 和 2.0 之间的数值,默认为0 | 1 | number或者null | 正值会根据标记是否已在当前文本中出现进行惩罚,从而提高模型讨论新话题的可能性 | |
| responseformat | 指定模型输出格式的对象 | 1 | object | ||
| Text | 默认文本响应格式 | 2 | object | ||
| type | 所定义的响应格式类型。始终为文本 | 3 | string | 是 | |
| JSON schema | JSON 模式响应格式。用于生成结构化的 JSON 响应 | 2 | object | ||
| jsonschema | 结构化输出的配置选项,包括一个JSON模式 | 3 | object | 是 | |
| name | 响应格式的名称。必须由 a-z、A-Z、0-9 组成,或包含下划线和连字符,且最大长度为 64 | 4 | string | 是 | |
| description | 对该响应格式用途的描述,供模型判断如何以该格式进行回应 | 4 | string | ||
| schema | 响应格式的模式,以 JSON 模式对象的形式描述 | 4 | object | ||
| strict | 生成输出时是否启用严格的模式遵循。默认为false,如果设置为true,模型将始终遵循schema字段中定义的确切模式。当strict为true时,仅支持JSON Schema的一个子集 | 4 | boolean or null | ||
| type | 响应格式的类型,固定为jsonobject | 3 | string | 是 | |
| JSON object | JSON 对象响应格式 | 2 | object | 这是一种较旧的生成 JSON 响应的方法。对于支持 jsonschema 的模型,建议使用 jsonschema。请注意,如果没有系统消息或用户消息指示模型生成 JSON,模型将不会生成 JSON | |
| type | 所定义的响应格式类型。始终为 jsonobject | 3 | string | 是 | |
| seed | (已弃用)若指定该参数,系统将尽力实现确定性采样(相同seed和参数的重复请求应返回相同结果)。确定性不保证,需通过systemfingerprint响应参数监测后端变更 | 1 | integer或者null | 该功能目前处于测试阶段 | |
| stop | 最新推理模型 o3 和 o4-mini 不支持此参数,默认为null | 1 | string/array/null | 最多可设置 4 个停止序列,当 API 生成到这些序列时会终止输出(返回的文本不包含停止序列本身) | |
| store | 是否存储本次聊天补全请求的输出,用于模型蒸馏或评估产品,默认为false | 1 | boolean或者null | 支持文本和图像输入 注意:超过 10MB 的图像输入将被丢弃 | |
| stream | 若设为 true,模型响应数据将通过服务器发送事件(SSE)流式传输,默认为false | 1 | boolean或者null | ||
| streamoptions | 流式回答的可选项(只有stream被设置为true是才有效),默认为null | 1 | object或者null | ||
| includeobfuscation | 启用流混淆时(默认 true),会在流式事件中添加随机字符以标准化负载大小(防御旁路攻击)。设为 false 可节省带宽(需确保网络链路可信 | 2 | boolean | ||
| includeusage | 若启用,会在最终 data: DONE 消息前发送一个额外数据块: usage 字段包含整个请求的 token 统计 choices 字段始终为空数组注意:若流中断,可能无法收到包含总 token 消耗的最终数据块 | 2 | boolean | ||
| temperature | 采样温度值(范围 0-2),默认为1 | 1 | number或者null | 较高值(如 0.8)会增加输出的随机性 较低值(如 0.2)会使输出更集中和确定 建议与 topp 参数二选一使用 | |
| toolchoice | 控制模型是否(以及如何)调用工具 | 1 | string或者object | none:不调用工具,直接生成消息(无工具时的默认值) auto:自动选择生成消息或调用工具(有工具时的默认值) required:必须调用一个或多个工具 指定工具:通过 {"type": "function", "function": {"name": "myfunction"}} 强制调用特定工具 | |
| Tool choice mode | 工具选择模式 | 2 | string | none:不调用工具,直接生成消息(无工具时的默认值) auto:自动选择生成消息或调用工具(有工具时的默认值) required:必须调用一个或多个工具 指定工具:通过 {"type": "function", "function": {"name": "myfunction"}} 强制调用特定工具 | |
| Function tool choice | 强制指定模型应调用的特定工具 | 2 | object | 用于强制模型调用特定函数 | |
| function | 3 | object | 是 | ||
| name | 需要调用函数的名字 | 4 | string | 是 | |
| type | tool的类型,当前仅支持function | 3 | object | 是 | |
| tools | 模型可调用的工具列表 | 1 | array | 当前仅支持将函数作为工具使用,用于提供模型可生成JSON输入的函数列表。最多支持128个函数 | |
| Function tool | 一种可用于生成回应的函数工具 | 2 | object | ||
| function | 3 | object | 是 | ||
| name | 被调用函数的名称。仅允许使用字母(a-z、A-Z)、数字(0-9)、下划线和短横线,最大长度64个字符 | 4 | string | 是 | |
| description | 函数功能的描述,用于帮助模型判断调用时机及方式 | 4 | string | ||
| parameters | 函数接受的参数,以JSON Schema格式描述 | 4 | object | ||
| strict | 是否在生成函数调用时启用严格模式。默认未false,若设为true,模型将严格遵循parameters中定义的JSON Schema结构 | 4 | boolean或者null | 严格模式下仅支持部分JSON Schema特性 | |
| type | 工具类型。当前仅支持function | 3 | string | 是 | |
| topp | 温度采样的替代方案——核采样(nucleus sampling),模型仅考虑概率质量累积在前topp区间的token。默认为1 | 1 | number或者null | 例如0.1表示仅考虑概率质量前10%的token。建议:调整此参数或temperature,但不要同时调整二者 |
返回结果
返回一个对话完成对象(chat completion object),如果请求启用了流式传输,则返回对话完成块对象(chat completion chunk objects)的流式序列
Openai 端点形式请求API
POSThttps://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/chat/completions
示例请求与响应结果
curl请求
curl https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${your_AK}" \
-d '{
"model": "gpt-5",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
响应结果
{
"id": "chatcmpl-B9MBs8CjcvOU2jLn4n570S5qMJKcT",
"object": "chat.completion",
"created": 1741569952,
"model": "gpt-4.1-2025-04-14",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?",
"refusal": null,
"annotations": []
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 19,
"completion_tokens": 10,
"total_tokens": 29,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default"
}
Openai 融合 Chat Completion请求API
POST https://genaiapi.cloudsway.net/v1/chat/completions
示例请求与响应结果
curl请求
curl https://genaiapi.cloudsway.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${your_AK}" \
-d '{
"model": "{MaaS Moddel Name}",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
响应结果
curl https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT_PATH}/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${your_AK}" \
-d '{
"model": "gpt-5",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
Openai 官方 Response API文档
同步模式
流式请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"input": "1+2+n=?",
"model": "gpt-o3-pro-2025-06-10",
"stream": true,
"reasoning": {
"effort": "high",
"summary": "auto"
}
}'
Tool call调用
第一次请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${your_AK}' \
--data '{
"model": "MaaS-o3-mini-2025-01-31",
"input": "What is the weather like in Boston today?",
"tools": [
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location", "unit"]
}
}
],
"tool_choice": "auto"
}'
响应
{
"id": "resp_68906124c3f08190995b6b59b54bc1300718351d629a7990",
"object": "response",
"created_at": 1754292516,
"status": "completed",
"background": false,
"content_filters": null,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"model": "MaaS-o3-mini-2025-01-31",
"output": [
{
"id": "rs_6890612fc9448190be00d13682364ca30718351d629a7990",
"type": "reasoning",
"summary": []
},
{
"id": "fc_6890612fcb44819086adeb804dbd6dbf0718351d629a7990",
"type": "function_call",
"status": "completed",
"arguments": "{\"location\":\"Boston, MA\",\"unit\":\"fahrenheit\"}",
"call_id": "call_8KWaObBBaHuJsbGcgEQ6OWFK",
"name": "get_current_weather"
}
],
"parallel_tool_calls": true,
"previous_response_id": null,
"prompt_cache_key": null,
"reasoning": {
"effort": "medium",
"summary": null
},
"safety_identifier": null,
"service_tier": "default",
"store": true,
"temperature": 1.0,
"text": {
"format": {
"type": "text"
}
},
"tool_choice": "auto",
"tools": [
{
"type": "function",
"description": "Get the current weather in a given location",
"name": "get_current_weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location",
"unit"
]
},
"strict": true
}
],
"top_p": 1.0,
"truncation": "disabled",
"usage": {
"input_tokens": 77,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 28,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 105
},
"user": null,
"metadata": {}
}
第二次请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{endpoint}/responses' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${your_AK}' \
--data '{
"model": "MaaS-o3-mini-2025-01-31",
"input": [
{
"role": "user",
"content": "What is the weather like in Boston today?"
},
{
"id": "rs_6890612fc9448190be00d13682364ca30718351d629a7990",
"type": "reasoning",
"summary": []
},
{
"id": "fc_6890612fcb44819086adeb804dbd6dbf0718351d629a7990",
"type": "function_call",
"call_id": "call_8KWaObBBaHuJsbGcgEQ6OWFK",
"name": "get_current_weather",
"arguments": "{\"location\":\"Boston, MA\",\"unit\":\"fahrenheit\"}"
},
{
"type": "function_call_output",
"call_id": "call_8KWaObBBaHuJsbGcgEQ6OWFK",
"output": "68"
}
],
"tools": [
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location", "unit"]
}
}
]
}'
响应
{
"id": "resp_6890637dcef081909a45e5996c1004d20718351d629a7990",
"object": "response",
"created_at": 1754293117,
"status": "completed",
"background": false,
"content_filters": null,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"model": "MaaS-o3-mini-2025-01-31",
"output": [
{
"id": "msg_6890638be07481909fe137356876ea180718351d629a7990",
"type": "message",
"status": "completed",
"content": [
{
"type": "output_text",
"annotations": [],
"text": "The current temperature in Boston is 68 °F."
}
],
"role": "assistant"
}
],
"parallel_tool_calls": true,
"previous_response_id": null,
"prompt_cache_key": null,
"reasoning": {
"effort": "medium",
"summary": null
},
"safety_identifier": null,
"service_tier": "default",
"store": true,
"temperature": 1.0,
"text": {
"format": {
"type": "text"
}
},
"tool_choice": "auto",
"tools": [
{
"type": "function",
"description": "Get the current weather in a given location",
"name": "get_current_weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location",
"unit"
]
},
"strict": true
}
],
"top_p": 1.0,
"truncation": "disabled",
"usage": {
"input_tokens": 180,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 15,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 195
},
"user": null,
"metadata": {}
}
思考模式请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"input": "1+2+n=?",
"model": "MaaS-o3-mini-2025-01-31",
"reasoning": {
"effort": "high",
"summary": "detailed"
}
}'
思考模式响应
{
"id": "resp_68904df39c0c8190a11c8a48c8f84957006db06e07770eb8",
"model": "MaaS-o3-mini-2025-01-31",
"background": false,
"instructions": null,
"object": "response",
"output": [
{
"summary": [
{
"type": "summary_text",
"text": "**Simplifying an expression**\n\nI see the user is asking for the result of 1 + 2 + n. Without context, I can just give them the symbolic expression: 3 + n. If n is an integer, it might help to ask for clarification about n, but since it's unknown, the result remains 3 + n. The user may initially want to see that mathematical expression, so I’ll present it as 3 + n with that explanation. This all seems straightforward."
}
],
"type": "reasoning",
"id": "rs_68904e02c9488190b84ddd71c371c68d006db06e07770eb8"
},
{
"role": "assistant",
"type": "message",
"content": [
{
"annotations": [],
"type": "output_text",
"text": "Without knowing the value of n, the sum remains symbolic:\n\n1 + 2 + n = 3 + n"
}
],
"id": "msg_68904e05d5b481909afe35fbcb122312006db06e07770eb8",
"status": "completed"
}
],
"temperature": 1.0,
"text": {
"format": {
"type": "text"
}
},
"created_at": 1754287603,
"error": null,
"incomplete_details": null,
"max_output_tokens": null,
"metadata": {},
"output_text": null,
"parallel_tool_calls": true,
"previous_response_id": null,
"reasoning": {
"effort": "high",
"summary": "detailed"
},
"status": "completed",
"tool_choice": "auto",
"tools": [],
"top_p": 1.0,
"truncation": "disabled",
"user": null,
"usage": {
"input_tokens": 12,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 93,
"output_tokens_details": {
"reasoning_tokens": 64
},
"total_tokens": 105
}
}
图像识别
url格式的请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS-o3-mini-2025-01-31",
"input": [
{
"role": "user",
"content": [
{"type": "input_text", "text": "给我描述图里内容"},
{
"type": "input_image",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
]
}
]
}'
base64格式的请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS-o3-mini-2025-01-31",
"input": [
{
"role": "user",
"content": [
{"type": "input_text", "text": "给我描述图里内容"},
{
"type": "input_image",
"image_url": "data:image/png;base64,iVBORwxxxx"
}
]
}
]
}'
多轮对话请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"input": "1+1等于多少",
"model": "MaaS-o3-mini-2025-01-31",
"reasoning": {
"effort": "high",
"summary": "detailed"
}
}'
响应
{
"id": "resp_6892f0b52de48190951e6b39e336957b03dd80b38745bdda",
"model": "MaaS-o3-mini-2025-01-31",
"background": false,
"instructions": null,
"object": "response",
"output": [
{
"summary": [],
"type": "reasoning",
"id": "rs_6892f0c957308190bbda9ea58c26186f03dd80b38745bdda"
},
{
"role": "assistant",
"type": "message",
"content": [
{
"annotations": [],
"type": "output_text",
"text": "1+1等于2。"
}
],
"id": "msg_6892f0c9588c81908fdbb97e05cd07b503dd80b38745bdda",
"status": "completed"
}
],
"temperature": 1.0,
"text": {
"format": {
"type": "text"
}
},
"created_at": 1754460341,
"error": null,
"incomplete_details": null,
"max_output_tokens": null,
"max_tool_calls": null,
"metadata": {},
"output_text": null,
"parallel_tool_calls": true,
"previous_response_id": null,
"prompt": null,
"prompt_cache_key": null,
"reasoning": {
"effort": "high",
"summary": "detailed"
},
"safety_identifier": null,
"service_tier": "default",
"status": "completed",
"tool_choice": "auto",
"tools": [],
"top_logprobs": null,
"top_p": 1.0,
"truncation": "disabled",
"user": null,
"usage": {
"input_tokens": 12,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 13,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 25
}
}
第二次请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"input": "继续加1等于多少",
"model": "MaaS-o3-mini-2025-01-31",
"previous_response_id":"resp_6892f0b52de48190951e6b39e336957b03dd80b38745bdda",
"reasoning": {
"effort": "high",
"summary": "detailed"
}
}'
异步模式
请求
所有同步的请求加上 "background": true, 异步get 携带id 进行请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"input": "1+2+n=?",
"background": true,
"model": "MaaS-o3-mini-2025-01-31",
"stream": true,
"reasoning": {
"effort": "high",
"summary": "detailed"
}
}'
响应
{
"id": "resp_6894071015f48190ba7629ad68d68f850427f468a587cfc8",
"model": "MaaS-o3-mini-2025-01-31",
"background": true,
"instructions": null,
"object": "response",
"output": [],
"temperature": 1.0,
"text": {
"format": {
"type": "text"
}
},
"created_at": 1754531600,
"error": null,
"incomplete_details": null,
"max_output_tokens": null,
"max_tool_calls": null,
"metadata": {},
"output_text": null,
"parallel_tool_calls": true,
"previous_response_id": null,
"prompt": null,
"prompt_cache_key": null,
"reasoning": {
"effort": "medium"
},
"safety_identifier": null,
"service_tier": "auto",
"status": "queued",
"tool_choice": "auto",
"tools": null,
"top_logprobs": null,
"top_p": 1.0,
"truncation": "disabled",
"user": null,
"usage": null
}
Get请求
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses/resp_689329c4e7e0819096e0c35b597fabe00aecb4e10eaeff14?stream=false&api-version=preview' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json'
自定义工具
curl 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/responses' \
--header 'Authorization: Bearer ${your_AK}' \
--header 'Content-Type: application/json' \
--data '{
"model": "MaaS-o3-mini-2025-01-31",
"input": "What is the weather like in Boston today?",
"background": true,
"tools": [
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": [
"celsius",
"fahrenheit"
]
}
},
"required": [
"location",
"unit"
]
}
}
],
"tool_choice": {
"type": "allowed_tools",
"mode": "auto",
"tools": [
{
"type": "function",
"name": "get_current_weather"
}
]
}
}'