// (g)(h) invalid key, no auth, unknown model, retired slugs, malformed body, wrong content-type. import { raw, save } from "./lib.ts"; const msg = { messages: [{ role: "user", content: "hi" }], max_tokens: 5 }; const out: Record = {}; out.invalid_key = await raw("/chat/completions", { method: "POST", key: "sk-invalid-0000000000", body: JSON.stringify({ model: "deepseek-v4-flash", ...msg }) }); out.no_auth = await (async () => { const res = await fetch("https://api.deepseek.com/chat/completions", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ model: "deepseek-v4-flash", ...msg }) }); const t = await res.text(); let b: unknown = t; try { b = JSON.parse(t); } catch {} return { status: res.status, body: b }; })(); out.invalid_key_models = await raw("/models", { key: "sk-invalid-0000000000" }); out.unknown_model = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-v99", ...msg }) }); out.retired_deepseek_chat = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-chat", ...msg }) }); out.retired_deepseek_reasoner = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-reasoner", ...msg }) }); out.malformed_json = await raw("/chat/completions", { method: "POST", body: '{"model":"deepseek-v4-flash","messages":"nope"}' }); out.broken_json = await raw("/chat/completions", { method: "POST", body: '{"model":' }); out.empty_messages = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-v4-flash", messages: [] }) }); out.missing_model = await raw("/chat/completions", { method: "POST", body: JSON.stringify(msg) }); out.bad_role = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "deepseek-v4-flash", messages: [{ role: "robot", content: "hi" }], max_tokens: 5 }) }); save("06-errors.json", out); for (const [k, v] of Object.entries(out)) console.log(k, (v as any).status, JSON.stringify((v as any).body).slice(0, 300), JSON.stringify((v as any).headers ?? {}));