AI Native之Open AI Next

AI Native之Open AI  Next AI 如何快速和程序交互Open AIOpenAI API 提供了一个简洁的接口可用于访问最先进的 AI模型包括文本生成、自然语言处理、计算机视觉等等。创建 API 密钥并运行您的第一个 API 调用即可开始使用。了解如何生成文本、分析图像、构建智能体等等。当然还有其他平台,比如https://docs.newapi.pro/zh newapiopenai对于前端技术栈的人建议选择Next.js TypeScript OpenAI SDK Vercel AI SDK1. 创建密钥https://platform.openai.com/api-keys2. 给工程安装openai依赖npm install openai3. demo体验example.mjsimport OpenAI from openai; const client new OpenAI(); const response await client.responses.create({ model: gpt-5.5, input: Write a one-sentence bedtime story about a unicorn. }); console.log(response.output_text);如果遇到翻墙问题总是连接超时可以用下面这个代码import OpenAI from openai; import { ProxyAgent, fetch as undiciFetch } from undici; const proxyUrl process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy; const fetchImpl proxyUrl ? (url, init {}) undiciFetch(url, { ...init, dispatcher: new ProxyAgent(proxyUrl) }) : fetch; const client new OpenAI({ apiKey: process.env.OPENAI_API_KEY, timeout: 60_000, fetch: fetchImpl, }); const response await client.responses.create({ model: gpt-5.2, input: Write a one-sentence bedtime story about a unicorn. }); console.log(response.output_text);运行命令node example.mjs