gpt-6-sol

最后更新:2026-11-14

POSThttps://www.sagelib.com/responses

gpt-6-sol 模型的响应生成接口,OpenAI兼容,支持多轮上下文、流式输出、工具调用、结构化输出等。

接口鉴权方式请参考:API接入与鉴权

请求参数

请求头

参数名称 描述
*Authorization string 鉴权令牌,格式为 Bearer ${AIGATEWAY_TOKEN}
*Content-Type string 默认值:application/json
可选值:application/json
内容类型,固定为 application/json

Body 参数

参数名称 描述
*model string 默认值:gpt-6-sol
可选值:gpt-6-sol、gpt-6-luna
目标模型标识,固定为 gpt-6-sol
*input array 可选值:String, or content block array (image detail: auto / low / high)
对话输入,可为纯字符串或内容块数组(文本块 input_text、图像块 input_image)
instructions string 系统指令,等价于 Chat Completions 端的 system 消息
stream boolean 默认值:false
可选值:true、false
是否以流式(SSE)返回响应
stream_options object 可选值:include_usage、include_obfuscation
流式附加选项,仅在 stream=true 时生效
max_output_tokens integer 可选值:1 ~ 128000
最大输出 token 数(Responses 端;含推理 token)
reasoning object 默认值:context: all_turns
可选值:low、medium、high、xhigh、current_turn、concise、detailed
推理配置对象,控制推理深度、执行模式、跨轮推理项渲染与摘要粒度
text object 默认值:format.type: text
可选值:json_object、json_schema
文本输出配置,支持纯文本与结构化输出
tools array 工具定义数组,模型可据此发起工具调用;name / description / parameters 为顶层字段
tool_choice object 默认值:auto
可选值:none、auto、required
工具选择策略,依赖 tools 参数同时提供
parallel_tool_calls boolean 默认值:true
可选值:true、false
是否允许模型并行发起多个工具调用
prompt_cache_key string 提示缓存键,用于提升相似请求的缓存命中率
prompt_cache_options object 可选值:mode: implicit / explicit; ttl: 30m
提示缓存断点配置,默认由服务端选取一个隐式断点
service_tier string 默认值:auto
可选值:auto、default、flex、priority、fast
服务层级(计费与调度档位)
store boolean 默认值:false
可选值:true、false
是否存储本次响应,供后续 previous_response_id 续接
metadata object 附加元数据键值对,用于业务侧标记与检索
safety_identifier string 可选值:Up to 64
安全标识符,用于滥用追踪
previous_response_id string 上一轮响应 id,用于多轮续接并保留推理状态
truncation string 默认值:disabled
可选值:auto、disabled
上下文超限时的截断策略
include array 可选值:file_search_call.results、web_search_call.results、web_search_call.action.sources、message.input_image.image_url、computer_call_output.output.image_url、code_interpreter_call.outputs、reasoning.encrypted_content、message.output_text.logprobs
指定响应中额外回带的字段清单
max_tool_calls integer 单次请求允许的最大工具调用次数
context_management object 可选值:type: compaction
上下文压缩管理,可配 compact_threshold 指定触发压缩的 token 阈值
background boolean 默认值:false
可选值:true、false
是否以后台异步方式执行
conversation string 会话对象 id,用于在服务端持久化多轮上下文
prompt object 复用服务端已存储的提示模板(含变量与版本引用),与 input 二者必居其一

请求示例

curl -v 'https://www.sagelib.com/responses' \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-sol",
    "input": [
      {
        "role": "user",
        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
      }
    ]
  }'
import json
import requests

# Configure base variables
base_url = "https://www.sagelib.com"  # 把 base_url 换成你的网关地址 https://www.sagelib.com
api_key = "***"  # Replace with your Bearer token

url = f"https://www.sagelib.com/responses"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

data = {
    "model": "gpt-6-sol",
    "input": [
        {
            "role": "user",
            "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
        }
    ]
}

# Send the POST request
response = requests.post(url, headers=headers, json=data)

# Print the status code and the returned JSON data
print(f"Status Code: {response.status_code}")
try:
    print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
    print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class LlmStreamClient {
    public static void main(String[] args) {
        String baseUrl = "https://www.sagelib.com";
        String apiKey = "***";
        String url = "https://www.sagelib.com/responses";

        String jsonRequestBody = """
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ]
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
                .build();

        try {
            // Use ofInputStream to handle the streaming response
            HttpResponse<java.io.InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());

            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.body()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    if (line.startsWith("data:")) {
                        String data = line.substring(5).trim();
                        if ("[DONE]".equals(data)) {
                            break;
                        }
                        // Tip: you can bring in Gson or Jackson here to parse the JSON in data and extract delta.content
                        System.out.println("Received stream chunk: " + data);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    baseUrl := "https://www.sagelib.com"
    apiKey := "***"
    url := "https://www.sagelib.com/responses"

    jsonRequestBody := `
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ]
            }
`

    req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
    if err != nil {
        fmt.Println("Failed to create request:", err)
        return
    }
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    // Pretty-print the returned JSON data
    var prettyBody map[string]interface{}
    if err := json.Unmarshal(body, &prettyBody); err == nil {
        pretty, _ := json.MarshalIndent(prettyBody, "", "  ")
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(pretty))
    } else {
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(body))
    }
}
curl -v 'https://www.sagelib.com/responses' \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-sol",
    "input": [
      {
        "role": "user",
        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
      }
    ],
    "tools": [
      {
        "type": "function",
        "name": "get_weather",
        "description": "Get weather",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string"
            }
          },
          "required": [
            "city"
          ]
        }
      }
    ]
  }'
import json
import requests

# Configure base variables
base_url = "https://www.sagelib.com"  # 把 base_url 换成你的网关地址 https://www.sagelib.com
api_key = "***"  # Replace with your Bearer token

url = f"https://www.sagelib.com/responses"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

data = {
    "model": "gpt-6-sol",
    "input": [
        {
            "role": "user",
            "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
        }
    ],
    "tools": [
        {
            "type": "function",
            "name": "get_weather",
            "description": "Get weather",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string"
                    }
                },
                "required": [
                    "city"
                ]
            }
        }
    ]
}

# Send the POST request
response = requests.post(url, headers=headers, json=data)

# Print the status code and the returned JSON data
print(f"Status Code: {response.status_code}")
try:
    print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
    print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class LlmStreamClient {
    public static void main(String[] args) {
        String baseUrl = "https://www.sagelib.com";
        String apiKey = "***";
        String url = "https://www.sagelib.com/responses";

        String jsonRequestBody = """
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ],
                "tools": [
                    {
                        "type": "function",
                        "name": "get_weather",
                        "description": "Get weather",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "city": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "city"
                            ]
                        }
                    }
                ]
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
                .build();

        try {
            // Use ofInputStream to handle the streaming response
            HttpResponse<java.io.InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());

            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.body()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    if (line.startsWith("data:")) {
                        String data = line.substring(5).trim();
                        if ("[DONE]".equals(data)) {
                            break;
                        }
                        // Tip: you can bring in Gson or Jackson here to parse the JSON in data and extract delta.content
                        System.out.println("Received stream chunk: " + data);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    baseUrl := "https://www.sagelib.com"
    apiKey := "***"
    url := "https://www.sagelib.com/responses"

    jsonRequestBody := `
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ],
                "tools": [
                    {
                        "type": "function",
                        "name": "get_weather",
                        "description": "Get weather",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "city": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "city"
                            ]
                        }
                    }
                ]
            }
`

    req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
    if err != nil {
        fmt.Println("Failed to create request:", err)
        return
    }
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    // Pretty-print the returned JSON data
    var prettyBody map[string]interface{}
    if err := json.Unmarshal(body, &prettyBody); err == nil {
        pretty, _ := json.MarshalIndent(prettyBody, "", "  ")
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(pretty))
    } else {
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(body))
    }
}
curl -v 'https://www.sagelib.com/responses' \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "input": [
      {
        "content": [
          {
            "detail": "high",
            "image_url": "${image_url}",
            "type": "input_image"
          },
          {
            "text": "Carefully observe this image and describe the subject, scene, and style details.",
            "type": "input_text"
          }
        ],
        "role": "user"
      }
    ],
    "model": "gpt-6-sol"
  }'
import json
import requests

# Configure base variables
base_url = "https://www.sagelib.com"  # 把 base_url 换成你的网关地址 https://www.sagelib.com
api_key = "***"  # Replace with your Bearer token

url = f"https://www.sagelib.com/responses"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

data = {
    "input": [
        {
            "content": [
                {
                    "detail": "high",
                    "image_url": "${image_url}",
                    "type": "input_image"
                },
                {
                    "text": "Carefully observe this image and describe the subject, scene, and style details.",
                    "type": "input_text"
                }
            ],
            "role": "user"
        }
    ],
    "model": "gpt-6-sol"
}

# Send the POST request
response = requests.post(url, headers=headers, json=data)

# Print the status code and the returned JSON data
print(f"Status Code: {response.status_code}")
try:
    print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
    print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class LlmStreamClient {
    public static void main(String[] args) {
        String baseUrl = "https://www.sagelib.com";
        String apiKey = "***";
        String url = "https://www.sagelib.com/responses";

        String jsonRequestBody = """
            {
                "input": [
                    {
                        "content": [
                            {
                                "detail": "high",
                                "image_url": "${image_url}",
                                "type": "input_image"
                            },
                            {
                                "text": "Carefully observe this image and describe the subject, scene, and style details.",
                                "type": "input_text"
                            }
                        ],
                        "role": "user"
                    }
                ],
                "model": "gpt-6-sol"
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
                .build();

        try {
            // Use ofInputStream to handle the streaming response
            HttpResponse<java.io.InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());

            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.body()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    if (line.startsWith("data:")) {
                        String data = line.substring(5).trim();
                        if ("[DONE]".equals(data)) {
                            break;
                        }
                        // Tip: you can bring in Gson or Jackson here to parse the JSON in data and extract delta.content
                        System.out.println("Received stream chunk: " + data);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    baseUrl := "https://www.sagelib.com"
    apiKey := "***"
    url := "https://www.sagelib.com/responses"

    jsonRequestBody := `
            {
                "input": [
                    {
                        "content": [
                            {
                                "detail": "high",
                                "image_url": "${image_url}",
                                "type": "input_image"
                            },
                            {
                                "text": "Carefully observe this image and describe the subject, scene, and style details.",
                                "type": "input_text"
                            }
                        ],
                        "role": "user"
                    }
                ],
                "model": "gpt-6-sol"
            }
`

    req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
    if err != nil {
        fmt.Println("Failed to create request:", err)
        return
    }
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    // Pretty-print the returned JSON data
    var prettyBody map[string]interface{}
    if err := json.Unmarshal(body, &prettyBody); err == nil {
        pretty, _ := json.MarshalIndent(prettyBody, "", "  ")
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(pretty))
    } else {
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(body))
    }
}

响应参数

Body 参数

参数名称 描述
id string 响应唯一标识,形如 resp_...,可用于下一轮 previous_response_id 续接
object string 固定为 response
created_at integer 创建时间(Unix 秒)
status string 响应状态,正常为 completed
model string 实际执行的模型名
output array 输出条目数组,按顺序排列,常见条目类型为 reasoning(推理项)与 message(正文消息)
usage object
    input_tokens integer 输入 token 数
    output_tokens integer 输出 token 数
    total_tokens integer 总 token 数
    input_tokens_details object
        cached_tokens integer 命中缓存的输入 token 数
        cache_write_tokens integer 写入缓存的输入 token 数
    output_tokens_details object
        reasoning_tokens integer 输出中用于推理的 token 数
instructions string 实际生效的系统指令,未传时为空字符串
metadata object 请求携带的元数据,未传时为空对象
parallel_tool_calls boolean 实际生效的并行工具调用开关
prompt_cache_retention string 实际生效的缓存保留档位
reasoning object 实际生效的推理配置:context / mode / effort 三个子字段
service_tier string 实际生效的服务层级(可能与请求值不同)
temperature float 模型默认采样温度
text object 实际生效的文本配置:format.type 与 verbosity
tool_choice string 实际生效的工具选择策略
tools array 实际生效的工具定义数组;未传时为空数组,传入后会被规范化补全
top_p float 模型默认核采样值
top_logprobs integer 输出 logprobs 数量
background boolean 实际生效的后台执行开关
completed_at integer 完成时间(Unix 秒)
truncation string 实际生效的截断策略
error object 错误信息,成功时为 null
incomplete_details object 未完成原因,成功时为 null
POSThttps://www.sagelib.com/openai/responses

gpt-6-sol 模型的响应生成接口,OpenAI 直连模式,支持多轮上下文、流式输出、工具调用、结构化输出等。

接口鉴权方式请参考:API接入与鉴权

请求参数

请求头

参数名称 描述
*Authorization string 鉴权令牌,格式为 Bearer ${AIGATEWAY_TOKEN}
*Content-Type string 默认值:application/json
可选值:application/json
内容类型,固定为 application/json

Body 参数

参数名称 描述
*model string 默认值:gpt-6-sol
可选值:gpt-6-sol、gpt-6-luna
目标模型标识,固定为 gpt-6-sol
*input array 可选值:String, or content block array (image detail: auto / low / high)
对话输入,可为纯字符串或内容块数组(文本块 input_text、图像块 input_image)
instructions string 系统指令,等价于 Chat Completions 端的 system 消息
stream boolean 默认值:false
可选值:true、false
是否以流式(SSE)返回响应
stream_options object 可选值:include_usage、include_obfuscation
流式附加选项,仅在 stream=true 时生效
max_output_tokens integer 可选值:1 ~ 128000
最大输出 token 数(Responses 端;含推理 token)
reasoning object 默认值:context: all_turns
可选值:low、medium、high、xhigh、current_turn、concise、detailed
推理配置对象,控制推理深度、执行模式、跨轮推理项渲染与摘要粒度
text object 默认值:format.type: text
可选值:json_object、json_schema
文本输出配置,支持纯文本与结构化输出
tools array 工具定义数组,模型可据此发起工具调用;name / description / parameters 为顶层字段
tool_choice object 默认值:auto
可选值:none、auto、required
工具选择策略,依赖 tools 参数同时提供
parallel_tool_calls boolean 默认值:true
可选值:true、false
是否允许模型并行发起多个工具调用
prompt_cache_key string 提示缓存键,用于提升相似请求的缓存命中率
prompt_cache_options object 可选值:mode: implicit / explicit; ttl: 30m
提示缓存断点配置,默认由服务端选取一个隐式断点
service_tier string 默认值:auto
可选值:auto、default、flex、priority、fast
服务层级(计费与调度档位)
store boolean 默认值:false
可选值:true、false
是否存储本次响应,供后续 previous_response_id 续接
metadata object 附加元数据键值对,用于业务侧标记与检索
safety_identifier string 可选值:Up to 64
安全标识符,用于滥用追踪
previous_response_id string 上一轮响应 id,用于多轮续接并保留推理状态
truncation string 默认值:disabled
可选值:auto、disabled
上下文超限时的截断策略
include array 可选值:file_search_call.results、web_search_call.results、web_search_call.action.sources、message.input_image.image_url、computer_call_output.output.image_url、code_interpreter_call.outputs、reasoning.encrypted_content、message.output_text.logprobs
指定响应中额外回带的字段清单
max_tool_calls integer 单次请求允许的最大工具调用次数
context_management object 可选值:type: compaction
上下文压缩管理,可配 compact_threshold 指定触发压缩的 token 阈值
background boolean 默认值:false
可选值:true、false
是否以后台异步方式执行
conversation string 会话对象 id,用于在服务端持久化多轮上下文
prompt object 复用服务端已存储的提示模板(含变量与版本引用),与 input 二者必居其一

请求示例

curl -v 'https://www.sagelib.com/openai/responses' \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-sol",
    "input": [
      {
        "role": "user",
        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
      }
    ]
  }'
import json
import requests

# Configure base variables
base_url = "https://www.sagelib.com"  # 把 base_url 换成你的网关地址 https://www.sagelib.com
api_key = "***"  # Replace with your Bearer token

url = f"https://www.sagelib.com/openai/responses"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

data = {
    "model": "gpt-6-sol",
    "input": [
        {
            "role": "user",
            "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
        }
    ]
}

# Send the POST request
response = requests.post(url, headers=headers, json=data)

# Print the status code and the returned JSON data
print(f"Status Code: {response.status_code}")
try:
    print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
    print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class LlmStreamClient {
    public static void main(String[] args) {
        String baseUrl = "https://www.sagelib.com";
        String apiKey = "***";
        String url = "https://www.sagelib.com/openai/responses";

        String jsonRequestBody = """
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ]
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
                .build();

        try {
            // Use ofInputStream to handle the streaming response
            HttpResponse<java.io.InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());

            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.body()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    if (line.startsWith("data:")) {
                        String data = line.substring(5).trim();
                        if ("[DONE]".equals(data)) {
                            break;
                        }
                        // Tip: you can bring in Gson or Jackson here to parse the JSON in data and extract delta.content
                        System.out.println("Received stream chunk: " + data);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    baseUrl := "https://www.sagelib.com"
    apiKey := "***"
    url := "https://www.sagelib.com/openai/responses"

    jsonRequestBody := `
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ]
            }
`

    req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
    if err != nil {
        fmt.Println("Failed to create request:", err)
        return
    }
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    // Pretty-print the returned JSON data
    var prettyBody map[string]interface{}
    if err := json.Unmarshal(body, &prettyBody); err == nil {
        pretty, _ := json.MarshalIndent(prettyBody, "", "  ")
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(pretty))
    } else {
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(body))
    }
}
curl -v 'https://www.sagelib.com/openai/responses' \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-sol",
    "input": [
      {
        "role": "user",
        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
      }
    ],
    "tools": [
      {
        "type": "function",
        "name": "get_weather",
        "description": "Get weather",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string"
            }
          },
          "required": [
            "city"
          ]
        }
      }
    ]
  }'
import json
import requests

# Configure base variables
base_url = "https://www.sagelib.com"  # 把 base_url 换成你的网关地址 https://www.sagelib.com
api_key = "***"  # Replace with your Bearer token

url = f"https://www.sagelib.com/openai/responses"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

data = {
    "model": "gpt-6-sol",
    "input": [
        {
            "role": "user",
            "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
        }
    ],
    "tools": [
        {
            "type": "function",
            "name": "get_weather",
            "description": "Get weather",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string"
                    }
                },
                "required": [
                    "city"
                ]
            }
        }
    ]
}

# Send the POST request
response = requests.post(url, headers=headers, json=data)

# Print the status code and the returned JSON data
print(f"Status Code: {response.status_code}")
try:
    print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
    print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class LlmStreamClient {
    public static void main(String[] args) {
        String baseUrl = "https://www.sagelib.com";
        String apiKey = "***";
        String url = "https://www.sagelib.com/openai/responses";

        String jsonRequestBody = """
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ],
                "tools": [
                    {
                        "type": "function",
                        "name": "get_weather",
                        "description": "Get weather",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "city": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "city"
                            ]
                        }
                    }
                ]
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
                .build();

        try {
            // Use ofInputStream to handle the streaming response
            HttpResponse<java.io.InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());

            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.body()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    if (line.startsWith("data:")) {
                        String data = line.substring(5).trim();
                        if ("[DONE]".equals(data)) {
                            break;
                        }
                        // Tip: you can bring in Gson or Jackson here to parse the JSON in data and extract delta.content
                        System.out.println("Received stream chunk: " + data);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    baseUrl := "https://www.sagelib.com"
    apiKey := "***"
    url := "https://www.sagelib.com/openai/responses"

    jsonRequestBody := `
            {
                "model": "gpt-6-sol",
                "input": [
                    {
                        "role": "user",
                        "content": "What model are you? Which company made you? When were you launched? Briefly describe your capability boundaries."
                    }
                ],
                "tools": [
                    {
                        "type": "function",
                        "name": "get_weather",
                        "description": "Get weather",
                        "parameters": {
                            "type": "object",
                            "properties": {
                                "city": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "city"
                            ]
                        }
                    }
                ]
            }
`

    req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
    if err != nil {
        fmt.Println("Failed to create request:", err)
        return
    }
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    // Pretty-print the returned JSON data
    var prettyBody map[string]interface{}
    if err := json.Unmarshal(body, &prettyBody); err == nil {
        pretty, _ := json.MarshalIndent(prettyBody, "", "  ")
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(pretty))
    } else {
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(body))
    }
}
curl -v 'https://www.sagelib.com/openai/responses' \
  -H "Authorization: Bearer ***" \
  -H "Content-Type: application/json" \
  -d '{
    "input": [
      {
        "content": [
          {
            "detail": "high",
            "image_url": "${image_url}",
            "type": "input_image"
          },
          {
            "text": "Carefully observe this image and describe the subject, scene, and style details.",
            "type": "input_text"
          }
        ],
        "role": "user"
      }
    ],
    "model": "gpt-6-sol"
  }'
import json
import requests

# Configure base variables
base_url = "https://www.sagelib.com"  # 把 base_url 换成你的网关地址 https://www.sagelib.com
api_key = "***"  # Replace with your Bearer token

url = f"https://www.sagelib.com/openai/responses"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

data = {
    "input": [
        {
            "content": [
                {
                    "detail": "high",
                    "image_url": "${image_url}",
                    "type": "input_image"
                },
                {
                    "text": "Carefully observe this image and describe the subject, scene, and style details.",
                    "type": "input_text"
                }
            ],
            "role": "user"
        }
    ],
    "model": "gpt-6-sol"
}

# Send the POST request
response = requests.post(url, headers=headers, json=data)

# Print the status code and the returned JSON data
print(f"Status Code: {response.status_code}")
try:
    print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
    print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class LlmStreamClient {
    public static void main(String[] args) {
        String baseUrl = "https://www.sagelib.com";
        String apiKey = "***";
        String url = "https://www.sagelib.com/openai/responses";

        String jsonRequestBody = """
            {
                "input": [
                    {
                        "content": [
                            {
                                "detail": "high",
                                "image_url": "${image_url}",
                                "type": "input_image"
                            },
                            {
                                "text": "Carefully observe this image and describe the subject, scene, and style details.",
                                "type": "input_text"
                            }
                        ],
                        "role": "user"
                    }
                ],
                "model": "gpt-6-sol"
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
                .build();

        try {
            // Use ofInputStream to handle the streaming response
            HttpResponse<java.io.InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());

            try (BufferedReader reader = new BufferedReader(new InputStreamReader(response.body()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    if (line.startsWith("data:")) {
                        String data = line.substring(5).trim();
                        if ("[DONE]".equals(data)) {
                            break;
                        }
                        // Tip: you can bring in Gson or Jackson here to parse the JSON in data and extract delta.content
                        System.out.println("Received stream chunk: " + data);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    baseUrl := "https://www.sagelib.com"
    apiKey := "***"
    url := "https://www.sagelib.com/openai/responses"

    jsonRequestBody := `
            {
                "input": [
                    {
                        "content": [
                            {
                                "detail": "high",
                                "image_url": "${image_url}",
                                "type": "input_image"
                            },
                            {
                                "text": "Carefully observe this image and describe the subject, scene, and style details.",
                                "type": "input_text"
                            }
                        ],
                        "role": "user"
                    }
                ],
                "model": "gpt-6-sol"
            }
`

    req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
    if err != nil {
        fmt.Println("Failed to create request:", err)
        return
    }
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Request failed:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    // Pretty-print the returned JSON data
    var prettyBody map[string]interface{}
    if err := json.Unmarshal(body, &prettyBody); err == nil {
        pretty, _ := json.MarshalIndent(prettyBody, "", "  ")
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(pretty))
    } else {
        fmt.Println("Status Code:", resp.StatusCode)
        fmt.Println(string(body))
    }
}

响应参数

Body 参数

参数名称 描述
id string 响应唯一标识,形如 resp_...,可用于下一轮 previous_response_id 续接
object string 固定为 response
created_at integer 创建时间(Unix 秒)
status string 响应状态,正常为 completed
model string 实际执行的模型名
output array 输出条目数组,按顺序排列,常见条目类型为 reasoning(推理项)与 message(正文消息)
usage object
    input_tokens integer 输入 token 数
    output_tokens integer 输出 token 数
    total_tokens integer 总 token 数
    input_tokens_details object
        cached_tokens integer 命中缓存的输入 token 数
        cache_write_tokens integer 写入缓存的输入 token 数
    output_tokens_details object
        reasoning_tokens integer 输出中用于推理的 token 数
instructions string 实际生效的系统指令,未传时为空字符串
metadata object 请求携带的元数据,未传时为空对象
parallel_tool_calls boolean 实际生效的并行工具调用开关
prompt_cache_retention string 实际生效的缓存保留档位
reasoning object 实际生效的推理配置:context / mode / effort 三个子字段
service_tier string 实际生效的服务层级(可能与请求值不同)
temperature float 模型默认采样温度
text object 实际生效的文本配置:format.type 与 verbosity
tool_choice string 实际生效的工具选择策略
tools array 实际生效的工具定义数组;未传时为空数组,传入后会被规范化补全
top_p float 模型默认核采样值
top_logprobs integer 输出 logprobs 数量
background boolean 实际生效的后台执行开关
completed_at integer 完成时间(Unix 秒)
truncation string 实际生效的截断策略
error object 错误信息,成功时为 null
incomplete_details object 未完成原因,成功时为 null