准备
先设置环境变量,避免把 Secret 写入 shell history。
准备bash
export MOFANG_API_KEY="<your-api-key>"
export MOFANG_BASE_URL="https://cloudnode.skin/v1"请求示例
使用 --fail-with-body 可以在 HTTP 失败时保留 JSON error envelope。流式请求额外使用 --no-buffer。
非流式bash
curl "https://cloudnode.skin/v1/chat/completions" \
--request POST \
--header "Authorization: Bearer $MOFANG_API_KEY" \
--header "Content-Type: application/json" \
--header "Idempotency-Key: quick-start-001" \
--data '{"max_completion_tokens": 256,"messages": [{"content": "请用一句话解释幂等性。","role": "user"}],"model": "YOUR_MODEL_ALIAS"}'Streaming SSEbash
curl --no-buffer "https://cloudnode.skin/v1/chat/completions" \
--request POST \
--header "Authorization: Bearer $MOFANG_API_KEY" \
--header "Content-Type: application/json" \
--data '{"model":"YOUR_MODEL_ALIAS","messages":[{"role":"user","content":"Hello"}],"stream":true,"stream_options":{"include_usage":true}}'