gpt-6-luna
最后更新:2026-11-14
POSThttps://www.sagelib.com/responses
gpt-6-luna 模型的响应生成接口,OpenAI兼容,支持多轮上下文、流式输出、工具调用、结构化输出等。
接口鉴权方式请参考:API接入与鉴权
请求参数
请求头
| 参数名称 | 描述 |
|---|---|
*Authorization string |
鉴权令牌,格式为 Bearer ${AIGATEWAY_TOKEN} |
*Content-Type string |
默认值:application/json 可选值:application/json 内容类型,固定为 application/json |
Body 参数
| 参数名称 | 描述 |
|---|---|
*model string |
默认值:gpt-6-luna 可选值:gpt-6-sol、gpt-6-luna 目标模型标识 |
*input array |
可选值:String, or content block array (type: input_text / input_image; input_image.detail: auto/low/high) Responses 端输入,可为字符串或内容块数组 |
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 端点) |
reasoning object |
默认值:context: all_turns 可选值:low、medium、high、xhigh、current_turn、concise、detailed Responses 端推理配置 |
text object |
默认值:format.type: text 可选值:json_object、json_schema Responses 端文本输出配置 |
tools array |
可选值:Array of tool definitions 工具定义数组,模型可据此发起工具调用 |
tool_choice object |
默认值:auto 可选值:none、auto 工具选择策略,依赖 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 characters 安全标识符,用于滥用追踪 |
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 上下文压缩管理 |
background boolean |
默认值:false 可选值:true、false 是否以后台异步方式执行,长任务可先返回再轮询结果 |
conversation string |
会话对象 id 或会话参数,用于在服务端持久化多轮上下文 |
prompt object |
复用服务端已存储的提示模板(含变量与版本引用) |
请求示例
curl -v 'https://www.sagelib.com/responses' \
-H "Authorization: Bearer ***" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna"
}'
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-luna"
}
# 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-luna"
}
""";
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-luna"
}
`
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 |
响应唯一标识 |
object string |
固定为 response |
created_at / completed_at integer |
创建与完成时间戳 |
status string |
响应状态,如 completed |
model string |
实际生效的模型名 |
output array |
输出项数组,按类型分元素 |
output[type=reasoning] object |
|
encrypted_content string |
加密的推理内容(base64) |
output[type=message] object |
|
content array |
|
phase string |
输出阶段,如 final_answer |
usage object |
|
input_tokens integer |
输入 token 数 |
output_tokens integer |
输出 token 数 |
total_tokens integer |
总 token 数 |
output_tokens_details object |
|
reasoning_tokens integer |
输出中用于推理的 token 数 |
input_tokens_details object |
|
cached_tokens integer |
命中缓存的输入 token 数 |
cache_write_tokens integer |
写入缓存的 token 数 |
parallel_tool_calls boolean |
实际生效的并行工具调用开关 |
prompt_cache_retention string |
实际生效的缓存保留时长 |
reasoning object |
实际生效的推理配置(context/mode/effort) |
service_tier string |
实际生效的服务层级 |
text object |
实际生效的文本输出配置(format/verbosity) |
tool_choice string |
实际生效的工具选择策略 |
tools array |
实际生效的工具清单 |
truncation string |
实际生效的截断策略 |
background boolean |
是否后台执行 |
error / incomplete_details object |
错误与未完成详情,正常时为 null |
POSThttps://www.sagelib.com/openai/responses
gpt-6-luna 模型的响应生成接口,OpenAI 直连模式,支持多轮上下文、流式输出、工具调用、结构化输出等。
接口鉴权方式请参考:API接入与鉴权
请求参数
请求头
| 参数名称 | 描述 |
|---|---|
*Authorization string |
鉴权令牌,格式为 Bearer ${AIGATEWAY_TOKEN} |
*Content-Type string |
默认值:application/json 可选值:application/json 内容类型,固定为 application/json |
Body 参数
| 参数名称 | 描述 |
|---|---|
*model string |
默认值:gpt-6-luna 可选值:gpt-6-sol、gpt-6-luna 目标模型标识 |
*input array |
可选值:String, or content block array (type: input_text / input_image; input_image.detail: auto/low/high) Responses 端输入,可为字符串或内容块数组 |
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 端点) |
reasoning object |
默认值:context: all_turns 可选值:low、medium、high、xhigh、current_turn、concise、detailed Responses 端推理配置 |
text object |
默认值:format.type: text 可选值:json_object、json_schema Responses 端文本输出配置 |
tools array |
可选值:Array of tool definitions 工具定义数组,模型可据此发起工具调用 |
tool_choice object |
默认值:auto 可选值:none、auto 工具选择策略,依赖 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 characters 安全标识符,用于滥用追踪 |
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 上下文压缩管理 |
background boolean |
默认值:false 可选值:true、false 是否以后台异步方式执行,长任务可先返回再轮询结果 |
conversation string |
会话对象 id 或会话参数,用于在服务端持久化多轮上下文 |
prompt object |
复用服务端已存储的提示模板(含变量与版本引用) |
请求示例
curl -v 'https://www.sagelib.com/openai/responses' \
-H "Authorization: Bearer ***" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna",
"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-luna"
}'
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-luna"
}
# 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-luna"
}
""";
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-luna"
}
`
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 |
响应唯一标识 |
object string |
固定为 response |
created_at / completed_at integer |
创建与完成时间戳 |
status string |
响应状态,如 completed |
model string |
实际生效的模型名 |
output array |
输出项数组,按类型分元素 |
output[type=reasoning] object |
|
encrypted_content string |
加密的推理内容(base64) |
output[type=message] object |
|
content array |
|
phase string |
输出阶段,如 final_answer |
usage object |
|
input_tokens integer |
输入 token 数 |
output_tokens integer |
输出 token 数 |
total_tokens integer |
总 token 数 |
output_tokens_details object |
|
reasoning_tokens integer |
输出中用于推理的 token 数 |
input_tokens_details object |
|
cached_tokens integer |
命中缓存的输入 token 数 |
cache_write_tokens integer |
写入缓存的 token 数 |
parallel_tool_calls boolean |
实际生效的并行工具调用开关 |
prompt_cache_retention string |
实际生效的缓存保留时长 |
reasoning object |
实际生效的推理配置(context/mode/effort) |
service_tier string |
实际生效的服务层级 |
text object |
实际生效的文本输出配置(format/verbosity) |
tool_choice string |
实际生效的工具选择策略 |
tools array |
实际生效的工具清单 |
truncation string |
实际生效的截断策略 |
background boolean |
是否后台执行 |
error / incomplete_details object |
错误与未完成详情,正常时为 null |