/** * Manual test harness for the Inception provider plugin. * * Two modes: * node --import tsx test.ts discover # print models resolved from /v1/models * node --import tsx test.ts chat # stream a one-shot chat completion * * Requires INCEPTION_API_KEY in the environment for `chat`. */ // @ts-expect-error - runs under tsx, which resolves .ts imports import { discoverModels } from "./index.ts"; async function discover() { const models = await discoverModels(); for (const m of models) { console.log( `${m.id}\tctx=${m.contextWindow}\tmaxOut=${m.maxTokens}\tcost(in/out/cR/cW)=${m.cost.input}/${m.cost.output}/${m.cost.cacheRead}/${m.cost.cacheWrite}\tinput=[${m.input.join(",")}]`, ); } } async function chat() { const apiKey = process.env.INCEPTION_API_KEY; if (!apiKey) { console.error("INCEPTION_API_KEY is required for chat"); process.exit(1); } const response = await fetch("https://api.inceptionlabs.ai/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ model: "mercury-2", messages: [{ role: "user", content: "Say hello in exactly 3 words." }], max_tokens: 100, }), }); if (!response.ok || !response.body) { console.error(`HTTP ${response.status}: ${await response.text()}`); process.exit(1); } for await (const chunk of response.body) { process.stdout.write(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString()); } console.log(); } const mode = process.argv[2] ?? "discover"; if (mode === "chat") { chat().catch((e) => { console.error(e); process.exit(1); }); } else { discover().catch((e) => { console.error(e); process.exit(1); }); }