兼容 OpenAI 格式 · 生产接口文档

API 接口文档
更清晰的调用配置

使用一个 API Key 即可通过本接口调用对话、生图、视频等模型。本文将 Base URL 固定为 https://1.cnmz.de/v1,所有 curl 示例均可直接按该地址替换令牌后使用。

Bearer TokenChat CompletionsImagesVideosStreaming
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 URLhttps://1.cnmz.de/v1OpenAI SDK / 外部客户端填写该地址。
HeaderAuthorization: Bearer $NEW_API_KEY所有受保护接口均需要。
Content-Typeapplication/jsonPOST JSON 请求建议显式传入。
SDK

客户端配置

大多数 OpenAI 兼容客户端只需要改两个值:api_keybase_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
  }'
参数类型说明
modelstring必填。使用已开放的模型名称。
messagesarray必填。OpenAI 消息数组。
streamboolean可选。为 true 时返回 SSE 流。
temperaturenumber可选。按模型支持情况转发。
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

视频生成

视频生成采用异步任务流程:先提交任务,再轮询状态,成功后读取或下载视频内容。

方法完整路径用途
POSThttps://1.cnmz.de/v1/videos创建视频任务
GEThttps://1.cnmz.de/v1/videos/{task_id}获取任务状态
GEThttps://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.mp4

JavaScript 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)
参数类型说明
modelstring必填。2.0 fast 视频通道可使用 video-ds-2.0-fast
promptstring必填。清晰描述要生成的视频内容。
secondsinteger可选。当前 fast 视频流程主要按 15 秒设计。
aspect_ratioenum可选。常用值包括 9:1616:91:1
imagesarray可选。参考图片 URL 或 base64 图片,数量以当前上游限制为准。
videosarray可选。参考视频 URL,数量以当前上游限制为准。
audiosarray可选。参考音频 URL,通常传 1 个音频文件。
MAP

接口速览

以下路径均相对于 https://1.cnmz.de/v1。如果工具要求填写完整 URL,请将 Base URL 与路径拼接。

方法相对路径说明
GET/models获取可用模型列表。
POST/chat/completionsOpenAI 兼容对话补全。
POST/responsesOpenAI Responses API 兼容格式。
POST/images/generations创建图片生成任务。
POST/images/edits编辑图片。
POST/embeddings创建文本嵌入。
POST/audio/transcriptions音频转录。
POST/audio/speech文本转语音。
POST/rerank文档重排序。
POST/videos创建视频任务。
ERR

常见错误

外部对接时建议同时读取 HTTP 状态码与响应体中的 error.type,这样可以稳定区分鉴权、余额、限速和上游失败。

状态码类型含义
401invalid_token令牌缺失、过期或无效。
403insufficient_quota用户余额不足,或当前分组没有权限。
404invalid_request_error任务 ID 不存在,或路径 / 参数错误。
429rate_limit_error用户、分组或上游供应商触发临时限速。
502server_error上游供应商失败、拦截提示词或返回了无效结果。
错误响应示例
{
  "error": {
    "message": "No Authorization header",
    "type": "invalid_token",
    "code": 401
  }
}
已复制到剪贴板