deCloud
MA CHAIN · 20260131
deCloud Docs

Code examples

Copyable cURL, Python, Node.js and SSE examples.

On this page

cURL

Set DECLOUD_API_KEY and choose an authorized model; examples use the site's shared model configuration.

curl https://macdecloud.com/v1/chat/completions \
  -H "Authorization: Bearer $DECLOUD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "deepseek/deepseek-chat",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}'

Python

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://macdecloud.com/v1",
    api_key=os.environ["DECLOUD_API_KEY"],
)
r = client.chat.completions.create(
    model="deepseek/deepseek-chat",
    messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)

Node.js

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://macdecloud.com/v1",
  apiKey: process.env.DECLOUD_API_KEY,
});
const r = await client.chat.completions.create({
  model: "deepseek/deepseek-chat",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);

Streaming SSE

Use stream: true for Chat Completions SSE; the gateway requests upstream usage. For completed streams with a report, read the usage chunk before the end. [DONE] is not JSON and some chunks have no choices. Missing upstream reports or interrupted streams may lack complete usage; check the console ledger.

curl https://macdecloud.com/v1/chat/completions \
  -H "Authorization: Bearer $DECLOUD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "deepseek/deepseek-chat",
  "stream": true,
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}'
Code examples · deCloud Docs