Build AI agents
without lock-in
Stark-Kit is a lightweight, strictly typed, and provider-agnostic TypeScript framework for building AI agents. Write your agentic loops once and run them on OpenAI, Claude, Gemini, or Mistral — no rewrites, no lock-in.
Write once, run anywhere.
Stark-Kit normalizes every provider's unique quirks, tool-calling formats, and streaming behaviors into one unified API.
Switching from OpenAI to Claude or Gemini is literally a single line of code. No need to rewrite your business logic, tools, or run loops.
Production-grade control.
Stark-Kit isn't just a toy wrapper. It gives you absolute control over the AI lifecycle with deeply integrated features built for real-world applications.
Lifecycle Guardrails
Intercept traffic at any point. Inject dynamic context, run toxicity checks, or enforce strict business rules before the LLM even sees the message.
Human-in-the-Loop
Never let AI execute dangerous actions unmonitored. Easily pause the run loop to require explicit human approval before a tool runs.
Structured Outputs
Force the LLM to reply perfectly in your Zod schema. No more broken JSON or parsing errors—just beautifully typed objects.
Install
bun add @mehularora/stark-kit zodPeer dep: zod
Minimal Example
import "dotenv/config";import { Agent, run, defineTool, ClaudeProvider } from "@mehularora/stark-kit";import z from "zod";
const provider = new ClaudeProvider({ model: "claude-3-5-sonnet-latest" });
const weatherTool = defineTool({ name: "getWeather", description: "Get the current weather for a city.", parameters: z.object({ city: z.string().describe("The name of the city"), }), execute: async ({ city }) => { return `The weather in ${city} is sunny and 22°C.`; },});
const agent = new Agent({ name: "WeatherBot", provider, instructions: "You are a helpful assistant. Keep answers brief.", tools: [weatherTool],});
const response = await run({ agent, messages: "What's the weather in Tokyo?" });
if (response.status === "complete") { console.log(response.content);}Everything you need
Production-grade primitives, not a toy wrapper.
Supported providers
Switch providers by swapping a single constructor. Your agent code stays the same.
| Provider | Adapter Class | Env Variable |
|---|---|---|
| OpenAI | OpenAIProvider | OPENAI_API_KEY |
| Claude | ClaudeProvider | ANTHROPIC_API_KEY |
| Gemini | GeminiProvider | GEMINI_API_KEY |
| Mistral | MistralProvider | MISTRAL_API_KEY |