@runbit/model
v0.1.1
Published
The model interface an agent talks to. Providers implement it; agents never import a provider.
Readme
@runbit/model
The model interface an agent talks to. Providers implement it; agents never import a provider.
npm install @runbit/modelimport { defineModel } from "@runbit/model";
import type { ChatModel } from "@runbit/model";
// Wrap any chat function into a ChatModel that emits llm:request / llm:response.
const echo = defineModel("echo", async ({ messages }) => ({
text: messages.at(-1)?.content ?? "",
usage: { inputTokens: 0, outputTokens: 0 },
}));ChatModel—{ name, chat(input, ctx) }.ChatInput/ChatOutput— messages + tool specs in;text,toolCalls,usageout.defineModel(name, fn)— adds event emission (including token usage) for free.
Real providers: @runbit/openai.
Part of Runbit — the AI Runtime. Everything executes through one small, event-driven runtime; agents, workflows, RAG, and observability are packages on top.
- Umbrella:
@runbit/runtime - License: MIT
