Responses API
NUWA 兼容 OpenAI 的 Responses API,保持与官方一致的参数与返回格式。只需替换 api_key 与 base_url 即可在国内直连,获得多模态、推理、搜索等完整能力。
能力概览
- Text / Image input:支持文本或图文混合输入
- Streaming:支持流式增量返回
- Web search & Deep research:实时搜索与深度研究
- Reasoning 深度:
minimal / low / medium / high,minimal仅 gpt-5 系列支持 - Verbosity 控制:gpt-5 系列支持
low / medium / high - 工具:函数调用、
image_generation、code_interpreter、mcp、Computer Use
快速开始
与官方 OpenAI SDK 的调用方式相同,只需替换 api_key 与 base_url。
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***", # 换成你在 NUWA 生成的密钥
base_url="https://api.nuwaapi.com/v1"
)
response = client.responses.create(
model="gpt-4o-mini",
input="Hello NUWA"
)
print(response)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4o-mini",
input: "Hello NUWA"
})
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4o-mini",
input: "Hello NUWA"
});
console.log(JSON.stringify(response, null, 2));
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4o-mini",
"input": "Hello NUWA"
}'
提示
- 关于模型摘要:默认关闭,可按
disabled > auto > None配置,auto为兼顾成本与效果的选项。 gpt-5-chat若未传入reasoning_effort,等同于不启用推理,可获得更快响应。- 深度研究模型建议使用
o1-deep-research、o1-mini-deep-research,仅支持responses端口。 - gpt-5 系列默认锁定过程一致性输出,不再使用传统
temperature、top_p干预。 - o 系列 / gpt-5 系列不再使用
max_tokens,请在responses端使用max_output_tokens控制上限。
功能示例
gpt-5 系列
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1"
)
response = client.responses.create(
model="gpt-5", # gpt-5, gpt-5-chat-latest, gpt-5-mini, gpt-5-nano
input="塔罗占卜为何有效,背后的原理和可迁移的方法是什么?Output format: Markdown",
reasoning={"effort": "minimal"},
text={"verbosity": "low"},
stream=True
)
for event in response:
print(event)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-5",
input: "塔罗占卜为何有效,背后的原理和可迁移的方法是什么?Output format: Markdown",
reasoning: { effort: "minimal" },
text: { verbosity: "low" }
})
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-5",
input: "塔罗占卜为何有效,背后的原理和可迁移的方法是什么?Output format: Markdown",
reasoning: { effort: "minimal" },
text: { verbosity: "low" },
stream: true
});
for await (const event of response) {
console.log(JSON.stringify(event, null, 2));
}
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-5",
"input": "塔罗占卜为何有效,背后的原理和可迁移的方法是什么?Output format: Markdown",
"reasoning": {"effort": "minimal"},
"text": {"verbosity": "low"},
"stream": true
}'
文本
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1"
)
response = client.responses.create(
model="gpt-4o-mini", # codex-mini-latest 也可用
input="Tell me a three sentence bedtime story about a unicorn."
)
print(response)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4o-mini",
input: "Tell me a three sentence bedtime story about a unicorn."
})
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4o-mini",
input: "Tell me a three sentence bedtime story about a unicorn."
});
console.log(JSON.stringify(response, null, 2));
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4o-mini",
"input": "Tell me a three sentence bedtime story about a unicorn."
}'
图文
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1"
)
response = client.responses.create(
model="gpt-4o-mini",
input=[
{
"role": "user",
"content": [
{"type": "input_text", "text": "what is in this image?"},
{"type": "input_image", "image_url": "https://picsum.photos/400/300"}
]
}
]
)
print(response)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4o-mini",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "what is in this image?" },
{ type: "input_image", image_url: "https://picsum.photos/400/300" }
]
}
]
})
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4o-mini",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "what is in this image?" },
{ type: "input_image", image_url: "https://picsum.photos/400/300" }
]
}
]
});
console.log(JSON.stringify(response, null, 2));
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4o-mini",
"input": [
{
"role": "user",
"content": [
{"type": "input_text", "text": "what is in this image?"},
{"type": "input_image", "image_url": "https://picsum.photos/400/300"}
]
}
]
}'
流式
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1"
)
response = client.responses.create(
model="gpt-4o-mini",
instructions="You are a helpful assistant.",
input="Hello!",
stream=True
)
for event in response:
print(event)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4o-mini",
instructions: "You are a helpful assistant.",
input: "Hello!",
stream: true
})
});
const text = await response.text();
console.log(text);
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4o-mini",
instructions: "You are a helpful assistant.",
input: "Hello!",
stream: true
});
for await (const event of response) {
console.log(JSON.stringify(event, null, 2));
}
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4o-mini",
"instructions": "You are a helpful assistant.",
"input": "Hello!",
"stream": true
}'
搜索
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1"
)
response = client.responses.create(
model="gpt-4o-mini", # codex-mini-latest 不支持搜索
tools=[{"type": "web_search_preview"}],
input="What was a positive news story from today?"
)
print(response)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4o-mini",
tools: [{ type: "web_search_preview" }],
input: "What was a positive news story from today?"
})
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4o-mini",
tools: [{ type: "web_search_preview" }] as any,
input: "What was a positive news story from today?"
});
console.log(JSON.stringify(response, null, 2));
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4o-mini",
"tools": [{"type": "web_search_preview"}],
"input": "What was a positive news story from today?"
}'
Deep Research
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1",
timeout=3600,
)
input_text = """
Research the economic impact of semaglutide on global healthcare systems.
Do:
- Include specific figures, trends, statistics, and measurable outcomes.
- Prioritize reliable, up-to-date sources: peer-reviewed research, health
organizations (e.g., WHO, CDC), regulatory agencies, or pharmaceutical
earnings reports.
- Include inline citations and return all source metadata.
Be analytical, avoid generalities, and ensure that each section supports
data-backed reasoning that could inform healthcare policy or financial modeling.
"""
response = client.responses.create(
model="o1-deep-research",
input=input_text,
tools=[
{"type": "web_search_preview"},
{"type": "code_interpreter", "container": {"type": "auto"}},
],
)
print(response.output_text)
const inputText = `
Research the economic impact of semaglutide on global healthcare systems.
Do:
- Include specific figures, trends, statistics, and measurable outcomes.
- Prioritize reliable, up-to-date sources: peer-reviewed research, health
organizations (e.g., WHO, CDC), regulatory agencies, or pharmaceutical
earnings reports.
- Include inline citations and return all source metadata.
Be analytical, avoid generalities, and ensure that each section supports
data-backed reasoning that could inform healthcare policy or financial modeling.
`;
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "o1-deep-research",
input: inputText,
tools: [
{ type: "web_search_preview" },
{ type: "code_interpreter", container: { type: "auto" } }
]
}),
signal: AbortSignal.timeout(3600000)
});
const data = await response.json();
console.log(data.output_text ?? JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1",
timeout: 3600000
});
const inputText = `
Research the economic impact of semaglutide on global healthcare systems.
Do:
- Include specific figures, trends, statistics, and measurable outcomes.
- Prioritize reliable, up-to-date sources: peer-reviewed research, health
organizations (e.g., WHO, CDC), regulatory agencies, or pharmaceutical
earnings reports.
- Include inline citations and return all source metadata.
Be analytical, avoid generalities, and ensure that each section supports
data-backed reasoning that could inform healthcare policy or financial modeling.
`;
async function main(): Promise<void> {
const response = await client.responses.create({
model: "o1-deep-research",
input: inputText,
tools: [
{ type: "web_search_preview" },
{ type: "code_interpreter", container: { type: "auto" } }
] as any
});
console.log((response as any).output_text);
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "o1-deep-research",
"input": "Research the economic impact of semaglutide on global healthcare systems.\nDo:\n- Include specific figures, trends, statistics, and measurable outcomes.\n- Prioritize reliable, up-to-date sources: peer-reviewed research, health organizations (e.g., WHO, CDC), regulatory agencies, or pharmaceutical earnings reports.\n- Include inline citations and return all source metadata.\n\nBe analytical, avoid generalities, and ensure that each section supports data-backed reasoning that could inform healthcare policy or financial modeling.",
"tools": [
{"type": "web_search_preview"},
{"type": "code_interpreter", "container": {"type": "auto"}}
]
}'
推理
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1",
)
response = client.responses.create(
model="o4-mini", # 支持 codex-mini-latest, o4-mini, o3-mini, o3, o1
input="How much wood would a woodchuck chuck?",
reasoning={
"effort": "medium", # low / medium / high
"summary": "auto",
},
)
print(response)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "o4-mini",
input: "How much wood would a woodchuck chuck?",
reasoning: {
effort: "medium",
summary: "auto"
}
})
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "o4-mini",
input: "How much wood would a woodchuck chuck?",
reasoning: {
effort: "medium",
summary: "auto"
} as any
});
console.log(JSON.stringify(response, null, 2));
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "o4-mini",
"input": "How much wood would a woodchuck chuck?",
"reasoning": {
"effort": "medium",
"summary": "auto"
}
}'
函数调用
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1",
)
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"],
},
}
]
response = client.responses.create(
model="gpt-4o-mini",
tools=tools,
input="What is the weather like in Boston today?",
tool_choice="auto",
)
print(response)
const 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"]
}
}];
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4o-mini",
input: "What is the weather like in Boston today?",
tool_choice: "auto",
tools
})
});
const data = await response.json();
console.log(JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
const 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"]
}
}];
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4o-mini",
input: "What is the weather like in Boston today?",
tool_choice: "auto",
tools: tools as any
});
console.log(JSON.stringify(response, null, 2));
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4o-mini",
"input": "What is the weather like in Boston today?",
"tool_choice": "auto",
"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"]
}
}]
}'
图像生成工具
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
import base64
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1",
)
response = client.responses.create(
model="gpt-4.1-mini",
input="Generate an image of gray tabby cat hugging an otter with an orange scarf",
tools=[
{
"type": "image_generation",
"background": "opaque",
"quality": "high",
}
],
)
image_data = [
output.result
for output in response.output
if output.type == "image_generation_call"
]
if image_data:
with open("cat_and_otter.png", "wb") as f:
f.write(base64.b64decode(image_data[0]))
const fs = require("fs");
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4.1-mini",
input: "Generate an image of gray tabby cat hugging an otter with an orange scarf",
tools: [
{
type: "image_generation",
background: "opaque",
quality: "high"
}
]
})
});
const data = await response.json();
const call = (data.output ?? []).find(item => item.type === "image_generation_call");
if (call?.result) {
fs.writeFileSync("cat_and_otter.png", Buffer.from(call.result, "base64"));
console.log("✅ 图片已保存为 cat_and_otter.png");
} else {
console.log(JSON.stringify(data, null, 2));
}
import OpenAI from "openai";
import fs from "fs";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4.1-mini",
input: "Generate an image of gray tabby cat hugging an otter with an orange scarf",
tools: [
{
type: "image_generation",
background: "opaque",
quality: "high"
}
] as any
});
const output = (response as any).output ?? [];
const call = output.find((item: any) => item.type === "image_generation_call");
if (call?.result) {
fs.writeFileSync("cat_and_otter.png", Buffer.from(call.result, "base64"));
console.log("✅ 图片已保存为 cat_and_otter.png");
} else {
console.log(JSON.stringify(response, null, 2));
}
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4.1-mini",
"input": "Generate an image of gray tabby cat hugging an otter with an orange scarf",
"tools": [{
"type": "image_generation",
"background": "opaque",
"quality": "high"
}]
}' -o response.json
python -c "
import json, base64
with open('response.json', 'r', encoding='utf-8') as f:
data = json.load(f)
items = data.get('output', [])
call = next((x for x in items if x.get('type') == 'image_generation_call'), None)
if call and call.get('result'):
with open('cat_and_otter.png', 'wb') as out:
out.write(base64.b64decode(call['result']))
print('✅ 图片已保存为 cat_and_otter.png')
else:
print(json.dumps(data, ensure_ascii=False, indent=2))
"
代码解析器
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1",
)
instructions = """
You are a personal math tutor. When asked a math question,
write and run code using the python tool to answer the question.
"""
response = client.responses.create(
model="gpt-4.1",
tools=[
{
"type": "code_interpreter",
"container": {"type": "auto"}
}
],
instructions=instructions,
input="I need to solve the equation 3x + 11 = 14. Can you help me?",
)
print(response.output)
const instructions = `
You are a personal math tutor. When asked a math question,
write and run code using the python tool to answer the question.
`;
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4.1",
tools: [{ type: "code_interpreter", container: { type: "auto" } }],
instructions,
input: "I need to solve the equation 3x + 11 = 14. Can you help me?"
})
});
const data = await response.json();
console.log(JSON.stringify(data.output ?? data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
const instructions = `
You are a personal math tutor. When asked a math question,
write and run code using the python tool to answer the question.
`;
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4.1",
tools: [{ type: "code_interpreter", container: { type: "auto" } }] as any,
instructions,
input: "I need to solve the equation 3x + 11 = 14. Can you help me?"
});
console.log(JSON.stringify((response as any).output, null, 2));
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4.1",
"instructions": "You are a personal math tutor. When asked a math question, write and run code using the python tool to answer the question.",
"input": "I need to solve the equation 3x + 11 = 14. Can you help me?",
"tools": [{
"type": "code_interpreter",
"container": {"type": "auto"}
}]
}'
MCP 调用
- Python
- JavaScript
- TypeScript
- Curl
from openai import OpenAI
client = OpenAI(
api_key="sk-***",
base_url="https://api.nuwaapi.com/v1",
)
response = client.responses.create(
model="gpt-4.1",
tools=[{
"type": "mcp",
"server_label": "deepwiki",
"server_url": "https://mcp.deepwiki.com/mcp",
"require_approval": "never",
"allowed_tools": ["ask_question"],
}],
input="What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?",
)
print(response.output_text)
const response = await fetch("https://api.nuwaapi.com/v1/responses", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "sk-***"
},
body: JSON.stringify({
model: "gpt-4.1",
input: "What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?",
tools: [{
type: "mcp",
server_label: "deepwiki",
server_url: "https://mcp.deepwiki.com/mcp",
require_approval: "never",
allowed_tools: ["ask_question"]
}]
})
});
const data = await response.json();
console.log(data.output_text ?? JSON.stringify(data, null, 2));
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-***",
baseURL: "https://api.nuwaapi.com/v1"
});
async function main(): Promise<void> {
const response = await client.responses.create({
model: "gpt-4.1",
tools: [{
type: "mcp",
server_label: "deepwiki",
server_url: "https://mcp.deepwiki.com/mcp",
require_approval: "never",
allowed_tools: ["ask_question"]
}] as any,
input: "What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?"
});
console.log((response as any).output_text);
}
main().catch(console.error);
curl https://api.nuwaapi.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: sk-***" \
-d '{
"model": "gpt-4.1",
"input": "What transport protocols does the 2025-03-26 version of the MCP spec (modelcontextprotocol/modelcontextprotocol) support?",
"tools": [{
"type": "mcp",
"server_label": "deepwiki",
"server_url": "https://mcp.deepwiki.com/mcp",
"require_approval": "never",
"allowed_tools": ["ask_question"]
}]
}'
已知限制
codex-mir-latest不支持搜索- Computer Use 需要配合 Playwright,参考 官方仓库
- 截图任务耗时较长时成功率会降低
- CAPTCHA / Cloudflare 验证可能触发循环校验