如何从 OpenAI 的 API 切换到 Smart AIPI(5 分钟指南)
从 OpenAI 的 API 切换到 Smart AIPI 的分步指南。修改你的 base URL,保留你的代码不变。适用于 Python、Node.js、cURL、LangChain、Cursor 等。
TL;DR: 将你的 base URL 改为 https://api.smartaipi.com/v1,并使用你的 Smart AIPI API key。其他一切保持不变——prompt、streaming、function calling、structured outputs。不到 5 分钟即可完成。每次 API 调用节省 75%。
要从 OpenAI 的 API 切换到 Smart AIPI,请将你的 base URL 改为 https://api.smartaipi.com/v1 并使用你的 Smart AIPI API key。其他一切——prompt、streaming、function calling、structured outputs——都保持不变。 整个过程不到 5 分钟。
第 1 步:创建免费账户
前往 smartaipi.com/signup 注册。你可以使用 GitHub、Google 或 Microsoft OAuth。每个账户都可获得免费额度——无需信用卡。
第 2 步:生成 API key
进入你的控制面板,点击 API Keys → Create API Key。为它命名并复制该 key。你只会看到它一次。
第 3 步:修改你的 base URL
这是唯一需要修改的地方。将 OpenAI 的 URL 替换为 Smart AIPI 的:
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="sk-proj-your-smart-aipi-key",
base_url="https://api.smartaipi.com/v1"
)
# 其他一切都完全保持不变
response = client.chat.completions.create(
model="gpt-5.3-codex",
messages=[{"role": "user", "content": "Hello!"}]
)
Node.js
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-proj-your-smart-aipi-key',
baseURL: 'https://api.smartaipi.com/v1',
});
const response = await client.chat.completions.create({
model: 'gpt-5.3-codex',
messages: [{ role: 'user', content: 'Hello!' }],
});
cURL
curl https://api.smartaipi.com/v1/chat/completions \
-H "Authorization: Bearer sk-proj-your-smart-aipi-key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.3-codex","messages":[{"role":"user","content":"Hello!"}]}'
环境变量(适用于 LangChain、Cursor、Continue 等)
export OPENAI_API_KEY=sk-proj-your-smart-aipi-key
export OPENAI_BASE_URL=https://api.smartaipi.com/v1
大多数框架和工具——LangChain、LlamaIndex、Cursor、Continue、Codex CLI——都会自动读取这些环境变量。
第 4 步:验证是否生效
发起一个测试请求并检查你的 Smart AIPI 控制面板。几秒内你就应该能在使用统计中看到该请求。
常见问题
Smart AIPI 支持 streaming 吗?
支持。设置 stream: true,并以完全相同的方式处理 Server-Sent Events。无需任何修改。
function calling 和工具使用是否可用?
完全支持。Tools、function calling、JSON mode、structured outputs——完整的 OpenAI API 规范都可以通过 Smart AIPI 使用。
使用 Anthropic API 格式的工具怎么办?
Smart AIPI 也支持 Anthropic API 格式(/v1/messages)。设置 ANTHROPIC_BASE_URL=https://api.smartaipi.com 后,为 Anthropic SDK 构建的工具将在后端使用 GPT-5.3 Codex。
我能节省多少?
每次 API 调用节省 75%。通过 Smart AIPI,GPT-5.3 Codex 输出成本为 $3.50/1M tokens,而直接使用 OpenAI 为 $14.00/1M。若你每月使用 10M tokens,可节省超过 $100。
我需要修改 prompt 或响应处理逻辑吗?
不需要。Smart AIPI 与 OpenAI 完全兼容。唯一的变化是 base URL。你的 prompt、响应解析、错误处理——一切都保持不变。