Model Nexus Docs
API 调用教程
给会写代码或要接入业务系统的人使用。普通用户优先配置 Codex 或 Claude Code。
API 调用适合谁
直接接入程序
API 调用适合会写代码、要接入业务系统,或想先用请求工具测试接口的人。Model Nexus 对外提供 OpenAI-compatible 地址:https://api.modelnexus.net/v1。
普通用户建议
如果只是想让 AI 帮你写代码,优先看 Codex、Claude Code、OpenCode 或 Oh My Pi 教程。
推荐 companion:Bruno
Windows / macOS / Linux 测试
- 从 Bruno 下载页安装 Windows 版。
- 新建 HTTP request,方法选 POST。
- URL 填
https://api.modelnexus.net/v1/responses。 - Header 加
Authorization: Bearer 你的 key和Content-Type: application/json。 - Body 使用下面 Responses 示例。
- 从 Bruno 下载页安装 macOS 版。
- 新建 HTTP request,方法选 POST。
- URL 填
https://api.modelnexus.net/v1/responses。 - Header 和 Body 与 Windows 相同。
- 从 Bruno 下载页安装 Linux 版,或使用终端里的 curl。
- 新建 HTTP request,方法选 POST。
- URL 填
https://api.modelnexus.net/v1/responses。 - Header 和 Body 与 Windows 相同。
查看模型列表
curl https://api.modelnexus.net/v1/models \
-H "Authorization: Bearer {{MODELNEXUS_API_KEY}}"
OpenAI Responses
curl https://api.modelnexus.net/v1/responses \
-H "Authorization: Bearer {{MODELNEXUS_API_KEY}}" \
-H "Content-Type: application/json" \
-d '{"model":"{{MODEL}}","input":"用一句话介绍 Model Nexus"}'
Python
from openai import OpenAI
client = OpenAI(api_key="{{MODELNEXUS_API_KEY}}", base_url="https://api.modelnexus.net/v1")
response = client.responses.create(model="{{MODEL}}", input="用一句话介绍 Model Nexus")
print(response.output_text)
常见问题
- 401:Authorization header 要写成
Bearer 你的 key。 - 404:直接 API 使用
https://api.modelnexus.net/v1。 - 模型不存在:先调用
/v1/models看 key 可用模型。