// Probe (g): invalid key, missing key, unknown model, bad body -> status + body + headers. import { raw, save, short } from "./lib.ts"; const results: Record = {}; results.invalidKey = await raw("/chat/completions", { key: "xai-invalid-key-000", method: "POST", body: JSON.stringify({ model: "grok-4.3", messages: [{ role: "user", content: "hi" }], max_completion_tokens: 5 }) }); results.invalidKeyModels = await raw("/models", { key: "xai-invalid-key-000" }); results.unknownModel = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "grok-99", messages: [{ role: "user", content: "hi" }], max_completion_tokens: 5 }) }); results.badBody = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "grok-4.3", messages: "nope" }) }); results.retiredAlias = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "grok-3", messages: [{ role: "user", content: "Reply: ok" }], max_completion_tokens: 5 }) }); results.retiredAlias2 = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "grok-4-fast-reasoning", messages: [{ role: "user", content: "Reply: ok" }], max_completion_tokens: 5 }) }); // no auth header at all const res = await fetch("https://api.x.ai/v1/models"); results.noAuth = { status: res.status, body: await res.text() }; for (const [k, v] of Object.entries(results)) console.log(k, (v as any).status, short((v as any).body, 300), JSON.stringify((v as any).headers ?? {})); save("06-errors.json", results);