SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
836 B · 11 lines typescript
Raw Blame History
1// STATUS: LIVE_VERIFIED — executed 2026-09-18 (exit 0 in 0.6s)2// Minimal Chat Completions call with the Node SDK.3import OpenAI from "openai";4import fs from "node:fs";56const client = new OpenAI();7const completion = await client.chat.completions.create({ model: "gpt-4.1-nano", messages: [{ role: "user", content: "Reply with OK." }], max_completion_tokens: 32 });8fs.appendFileSync("reports/live-requests.jsonl", JSON.stringify({ ts: new Date().toISOString().replace(/\.\d+Z$/, "Z"), provider: "openai", method: "POST", path: "/v1/chat/completions", status: 200, est_cost_usd: 0.000002, note: "example chat/minimal.ts" }) + "\n");9console.log(completion.choices[0].message.content, completion.choices[0].finish_reason, completion.usage);10if (!completion.choices[0].message.content?.includes("OK")) throw new Error("unexpected");11