// Misc: undocumented thinking.type=adaptive, stream without include_usage, non-thinking stream delta shape, logprobs shape, image silently dropped on pro. import { raw, rawSSE, save, pngDataUrl } from "./lib.ts"; const out: Record = {}; const m = "deepseek-v4-flash"; const hard = "A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost? Number only."; for (const [name, body] of Object.entries({ "adaptive_easy": { thinking: { type: "adaptive" }, messages: [{ role: "user", content: "Reply with the single word: pong" }] }, "adaptive_hard": { thinking: { type: "adaptive" }, messages: [{ role: "user", content: hard }] }, "adaptive+effort_low": { thinking: { type: "adaptive" }, reasoning_effort: "low", messages: [{ role: "user", content: hard }] }, "enabled_easy": { thinking: { type: "enabled" }, messages: [{ role: "user", content: "Reply with the single word: pong" }] }, })) { const r = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: m, max_tokens: 1500, ...body }) }); const b: any = r.body; out[name] = { status: r.status, finish: b.choices?.[0]?.finish_reason, content: b.choices?.[0]?.message?.content, reasoning_len: b.choices?.[0]?.message?.reasoning_content?.length ?? null, usage: b.usage, error: r.status !== 200 ? b : undefined }; console.log(name, r.status, JSON.stringify(b.usage?.completion_tokens_details), "rl", b.choices?.[0]?.message?.reasoning_content?.length ?? null, "→", JSON.stringify(b.choices?.[0]?.message?.content ?? b).slice(0, 120)); } // stream WITHOUT include_usage { const s = await rawSSE("/chat/completions", { model: m, messages: [{ role: "user", content: "Say hi." }], max_tokens: 100, stream: true, thinking: { type: "disabled" } }); const last = s.events.slice(-3); out.stream_no_include_usage = { status: s.status, last, deltaKeysFirst: Object.keys((s.events[0] as any)?.choices?.[0]?.delta ?? {}) }; console.log("stream no include_usage: usage on finish chunk?", JSON.stringify((last[0] as any)?.usage ?? (last[1] as any)?.usage), "first delta", JSON.stringify((s.events[0] as any)?.choices?.[0]?.delta)); } // stream thinking disabled + include_usage: do deltas still carry reasoning_content key? { const s = await rawSSE("/chat/completions", { model: m, messages: [{ role: "user", content: "Say hi." }], max_tokens: 100, stream: true, stream_options: { include_usage: true }, reasoning_effort: "none" }); out.stream_effort_none = { status: s.status, first2: s.events.slice(0, 2), last3: s.events.slice(-3) }; console.log("stream effort=none first delta", JSON.stringify((s.events[0] as any)?.choices?.[0]?.delta), "last", JSON.stringify(s.events.slice(-2)).slice(0, 500)); } // logprobs shape { const r = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: m, messages: [{ role: "user", content: "Say hi." }], max_tokens: 5, thinking: { type: "disabled" }, logprobs: true, top_logprobs: 2 }) }); out.logprobs = { status: r.status, logprobs: (r.body as any).choices?.[0]?.logprobs }; console.log("logprobs", JSON.stringify((r.body as any).choices?.[0]?.logprobs).slice(0, 400)); } // image on pro: is it dropped? ask a question only answerable from the image { const r = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-v4-pro", thinking: { type: "disabled" }, max_tokens: 60, messages: [{ role: "user", content: [{ type: "text", text: "Is there an image attached to this message? Answer yes or no and say what you received." }, { type: "image_url", image_url: { url: pngDataUrl(32, 32) } }] }] }) }); out.pro_image_dropped = { status: r.status, content: (r.body as any).choices?.[0]?.message?.content, usage: (r.body as any).usage }; console.log("pro image →", r.status, JSON.stringify(out.pro_image_dropped).slice(0, 400)); const r2 = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-v4-pro", thinking: { type: "disabled" }, max_tokens: 5, messages: [{ role: "user", content: [{ type: "text", text: "Is there an image attached to this message? Answer yes or no and say what you received." }] }] }) }); out.pro_text_only_tokens = (r2.body as any).usage; console.log("pro same text w/o image prompt_tokens", (r2.body as any).usage?.prompt_tokens, "vs with image", (r.body as any).usage?.prompt_tokens); } // /v1 streaming + trailing slash variants { const r = await raw("/v1/chat/completions/", { method: "POST", body: JSON.stringify({ model: m, messages: [{ role: "user", content: "hi" }], max_tokens: 2, thinking: { type: "disabled" } }) }); out.trailing_slash = { status: r.status, body: r.status === 200 ? "ok" : r.body }; console.log("trailing slash →", r.status); } save("10-misc.json", out);