GET
鉴权
在控制台创建 API Key 后,每次请求都通过 Authorization: Bearer <token> 发送。令牌示例统一使用环境变量 NEW_API_KEY,避免硬编码到代码仓库或前端页面。
重要:本文的 Base URL 已包含
/v1,因此客户端配置应填写 https://1.cnmz.de/v1;curl 中的完整模型列表地址为 https://1.cnmz.de/v1/models。Shell
export NEW_API_KEY="sk-your-token"
curl https://1.cnmz.de/v1/models \
-H "Authorization: Bearer $NEW_API_KEY"| 字段 | 值 | 说明 |
|---|---|---|
| Base URL | https://1.cnmz.de/v1 | OpenAI SDK / 外部客户端填写该地址。 |
| Header | Authorization: Bearer $NEW_API_KEY | 所有受保护接口均需要。 |
| Content-Type | application/json | POST JSON 请求建议显式传入。 |
SDK
客户端配置
大多数 OpenAI 兼容客户端只需要改两个值:api_key 和 base_url。下面示例适用于服务端运行环境。
Python
openai-python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NEW_API_KEY"],
base_url="https://1.cnmz.de/v1",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Say hello."}],
)
print(resp.choices[0].message.content)Node.js
openai-node
import OpenAI from "openai"
const client = new OpenAI({
apiKey: process.env.NEW_API_KEY,
baseURL: "https://1.cnmz.de/v1",
})
const resp = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Say hello." }],
})
console.log(resp.choices[0].message.content)POST
对话补全
对话接口兼容 OpenAI /chat/completions 格式。模型名称使用控制台或模型广场中展示的名称;如开启流式输出,设置 stream: true。
curl · /chat/completions
curl https://1.cnmz.de/v1/chat/completions \
-H "Authorization: Bearer $NEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "Say hello in one short sentence."}
],
"stream": true
}'| 参数 | 类型 | 说明 |
|---|---|---|
| model | string | 必填。使用已开放的模型名称。 |
| messages | array | 必填。OpenAI 消息数组。 |
| stream | boolean | 可选。为 true 时返回 SSE 流。 |
| temperature | number | 可选。按模型支持情况转发。 |
POST
图片生成
图片接口使用 /images/generations。不同上游模型支持的尺寸、质量、返回格式可能不同;中转会转发受支持的模型参数。
curl · /images/generations
curl https://1.cnmz.de/v1/images/generations \
-H "Authorization: Bearer $NEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A clean product photo of a white ceramic coffee cup on a desk",
"size": "1024x1024",
"n": 1
}'如果某个上游模型支持 4K 或更大尺寸,请按该上游模型文档传入对应
size 或扩展参数。POST
视频生成
视频生成采用异步任务流程:先提交任务,再轮询状态,成功后读取或下载视频内容。
| 方法 | 完整路径 | 用途 |
|---|---|---|
| POST | https://1.cnmz.de/v1/videos | 创建视频任务 |
| GET | https://1.cnmz.de/v1/videos/{task_id} | 获取任务状态 |
| GET | https://1.cnmz.de/v1/videos/{task_id}/content | 在线播放或下载 mp4 内容 |
提交文生视频任务
curl · text-to-video
curl https://1.cnmz.de/v1/videos \
-H "Authorization: Bearer $NEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "video-ds-2.0-fast",
"prompt": "A cinematic 9:16 video of a cat running through warm sunlight",
"seconds": 15,
"aspect_ratio": "9:16"
}'可选参考素材
curl · references
curl https://1.cnmz.de/v1/videos \
-H "Authorization: Bearer $NEW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "video-ds-2.0-fast",
"prompt": "Use the reference image style and create a smooth product video",
"seconds": 15,
"aspect_ratio": "9:16",
"images": ["https://example.com/input.png"],
"videos": ["https://example.com/input.mp4"],
"audios": ["https://example.com/input.mp3"]
}'轮询和下载
curl · poll/download
curl https://1.cnmz.de/v1/videos/{task_id} \
-H "Authorization: Bearer $NEW_API_KEY"
curl -L https://1.cnmz.de/v1/videos/{task_id}/content \
-H "Authorization: Bearer $NEW_API_KEY" \
-o result.mp4JavaScript fetch 示例
fetch
const response = await fetch('https://1.cnmz.de/v1/videos', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.NEW_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'video-ds-2.0-fast',
prompt: 'A smooth commercial video of a perfume bottle on glass',
seconds: 15,
aspect_ratio: '9:16',
}),
})
const task = await response.json()
console.log(task)| 参数 | 类型 | 说明 |
|---|---|---|
| model | string | 必填。2.0 fast 视频通道可使用 video-ds-2.0-fast。 |
| prompt | string | 必填。清晰描述要生成的视频内容。 |
| seconds | integer | 可选。当前 fast 视频流程主要按 15 秒设计。 |
| aspect_ratio | enum | 可选。常用值包括 9:16、16:9、1:1。 |
| images | array | 可选。参考图片 URL 或 base64 图片,数量以当前上游限制为准。 |
| videos | array | 可选。参考视频 URL,数量以当前上游限制为准。 |
| audios | array | 可选。参考音频 URL,通常传 1 个音频文件。 |
MAP
接口速览
以下路径均相对于 https://1.cnmz.de/v1。如果工具要求填写完整 URL,请将 Base URL 与路径拼接。
| 方法 | 相对路径 | 说明 |
|---|---|---|
| GET | /models | 获取可用模型列表。 |
| POST | /chat/completions | OpenAI 兼容对话补全。 |
| POST | /responses | OpenAI Responses API 兼容格式。 |
| POST | /images/generations | 创建图片生成任务。 |
| POST | /images/edits | 编辑图片。 |
| POST | /embeddings | 创建文本嵌入。 |
| POST | /audio/transcriptions | 音频转录。 |
| POST | /audio/speech | 文本转语音。 |
| POST | /rerank | 文档重排序。 |
| POST | /videos | 创建视频任务。 |
ERR
常见错误
外部对接时建议同时读取 HTTP 状态码与响应体中的 error.type,这样可以稳定区分鉴权、余额、限速和上游失败。
| 状态码 | 类型 | 含义 |
|---|---|---|
| 401 | invalid_token | 令牌缺失、过期或无效。 |
| 403 | insufficient_quota | 用户余额不足,或当前分组没有权限。 |
| 404 | invalid_request_error | 任务 ID 不存在,或路径 / 参数错误。 |
| 429 | rate_limit_error | 用户、分组或上游供应商触发临时限速。 |
| 502 | server_error | 上游供应商失败、拦截提示词或返回了无效结果。 |
错误响应示例
{
"error": {
"message": "No Authorization header",
"type": "invalid_token",
"code": 401
}
}