| 项目 | 内容 |
|---|---|
| Base URL | https://llm.ai-nebula.com/v1/chat/completions |
| 认证方式 | API Key (Token) |
| 请求头 | Authorization: Bearer sk-xxxx、Content-Type: application/json |
gpt-4o、gpt-4.1、gpt-4o-mini、gpt-3.5-turbo 等(以路由配置为准)tool_calls(content 通常为 null,finish_reason=tool_calls)。你需 要根据 tool_calls[*].function.name/arguments 在你的服务端执行对应函数。role:"tool" 消息回传给模型,并继续补全(可流式)。tool_call_id 必须与第一阶段返回一致。from openai import OpenAI
def gpt_5_input():
try:
# 初始化客户端
client = OpenAI(
api_key="******填写您的API密钥******", # 访问密钥
base_url="https://llm.ai-nebula.com/v1" # API服务地址
)
# 发送聊天请求
response = client.responses.create(
# 模型配置
model="gpt-5-chat",
input=[
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "分析这封信,并总结其关键点",
},
{
"type": "input_file",
"file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf",
},
],
},
]
)
return response.output_text
except Exception as e:
print(f"Error: {e}")
return None
if __name__ == "__main__":
# 调用示例
response = gpt_5_input()
print(response)import base64
from openai import OpenAI
client = OpenAI()
with open("draconomicon.pdf", "rb") as f:
data = f.read()
base64_string = base64.b64encode(data).decode("utf-8")
response = client.responses.create(
model="gpt-5-chat",
input=[
{
"role": "user",
"content": [
{
"type": "input_file",
"filename": "draconomicon.pdf",
"file_data": f"data:application/pdf;base64,{base64_string}",
},
{
"type": "input_text",
"text": "What is the first dragon in the book?",
},
],
},
]
)
print(response.output_text)choices、usageusage 聚合;若开启 stream_options.include_usage=true 的通道,分片可能包含实时用量response_format: json_schema 并提供严格的 JSON Schema;必要时配合降低 temperature、设置 max_tokenstool_calls,服务端执行函数并把结果再作为 tool 消息回传给模型seed;不同厂商实现可能差异,建议仅在需要可复现的链路开启temperature