Skip to content

SDK Reference

The Gambiarra SDK provides Vercel AI SDK integration for using shared LLMs in your applications.

Terminal window
npm install gambiarra-sdk
# or
bun add gambiarra-sdk
import { createGambiarra } from "gambiarra-sdk";
import { generateText } from "ai";
const gambiarra = createGambiarra({
roomCode: "ABC123",
hubUrl: "http://localhost:3000",
});
const result = await generateText({
model: gambiarra.any(),
prompt: "Hello, Gambiarra!",
});

Creates a Gambiarra provider instance.

Options:

OptionTypeDescriptionRequired
roomCodestringRoom code to connect toYes
hubUrlstringHub URLNo (auto-discover)

Route to any available participant.

const result = await generateText({
model: gambiarra.any(),
prompt: "Explain quantum computing",
});

Route to a specific participant by nickname.

const result = await generateText({
model: gambiarra.participant("joao"),
prompt: "Write a haiku about TypeScript",
});

Route to a participant with a specific model.

const result = await generateText({
model: gambiarra.model("llama3"),
prompt: "What is the meaning of life?",
});
import { streamText } from "ai";
const stream = await streamText({
model: gambiarra.model("llama3"),
prompt: "Write a story about a robot",
});
for await (const chunk of stream.textStream) {
process.stdout.write(chunk);
}
const result = await generateText({
model: gambiarra.any(),
prompt: "Explain recursion",
temperature: 0.7,
maxTokens: 500,
});