SPB Git forge

spb/polyllm

Public
15commits 1branches 0releases
2.2 MBsize
maindefault branch
13 days agolast push
TypeScript 97.4% SQL 1% JavaScript 0.9% CSS 0.6%
1.5 KB · 16 lines typescript
Raw Blame History
1// Probe (g): invalid key, missing key, unknown model, bad body -> status + body + headers.2import { raw, save, short } from "./lib.ts";34const results: Record<string, any> = {};5results.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 }) });6results.invalidKeyModels = await raw("/models", { key: "xai-invalid-key-000" });7results.unknownModel = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "grok-99", messages: [{ role: "user", content: "hi" }], max_completion_tokens: 5 }) });8results.badBody = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "grok-4.3", messages: "nope" }) });9results.retiredAlias = await raw("/chat/completions", { method: "POST", body: JSON.stringify({ model: "grok-3", messages: [{ role: "user", content: "Reply: ok" }], max_completion_tokens: 5 }) });10results.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 }) });11// no auth header at all12const res = await fetch("https://api.x.ai/v1/models");13results.noAuth = { status: res.status, body: await res.text() };14for (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 ?? {}));15save("06-errors.json", results);16