Fallbakit SDKs
Node.js SDK
Install and use the TypeScript SDK for Node 18+ with explicit constructor configuration.
Install
npm install fallbakitConfigure
The SDK does not read secrets automatically. Load the API key from your environment or secret manager and pass it into the constructor.
import { Fallbakit } from "fallbakit";
const apiKey = process.env.FALLBAKIT_API_KEY;
if (!apiKey) throw new Error("FALLBAKIT_API_KEY is required");
const client = new Fallbakit({
apiKey,
baseURL: process.env.FALLBAKIT_BASE_URL ?? "https://api.fallbakit.com",
timeout: 30_000,
});Chat completion
const response = await client.chat.completions.create({
model: "llama3.2",
messages: [{ role: "user", content: "Write a short welcome message" }],
fallbackProvider: "openai",
fallbackModel: "gpt-4o-mini",
fallback: true,
});
console.log(response.choices[0]?.message?.content);Streaming
const stream = await client.chat.completions.create({
model: "llama3.2",
messages: [{ role: "user", content: "Stream one sentence" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Streaming responses are exposed as an AsyncIterable.