Chat completions
POST /v1/chat/completions — request shape, streaming, and code samples in curl, JS, and Python.
Request#
POST /v1/chat/completions with the standard OpenAI body.
curl https://api.darkroom.computer/v1/chat/completions \
-H "Authorization: Bearer $DARKROOM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "darkroom/noir",
"messages": [{"role": "user", "content": "Explain the exploit class in this contract."}],
"stream": true
}'JavaScript (OpenAI SDK)#
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.darkroom.computer/v1",
apiKey: process.env.DARKROOM_API_KEY,
});
const stream = await client.chat.completions.create({
model: "darkroom/noir",
messages: [{ role: "user", content: "Write me a brief on X." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Python#
from openai import OpenAI
client = OpenAI(
base_url="https://api.darkroom.computer/v1",
api_key=os.environ["DARKROOM_API_KEY"],
)
resp = client.chat.completions.create(
model="darkroom/noir",
messages=[{"role": "user", "content": "Write me a brief on X."}],
)
print(resp.choices[0].message.content)Parameters#
| Field | Notes |
|---|---|
model | One of the Darkroom models, e.g. darkroom/noir. |
messages | Standard role / content array. darkroom/vision accepts image content parts. |
stream | true streams tokens as server-sent events; omit for a single buffered reply. |
temperature, max_tokens, … | Standard sampling parameters are passed through. |
Billing#
Calls meter against your wallet balance on input + output tokens, identical to the room.