Getting started
Quickstart
Build and run your first agent in 30 seconds.
Prerequisites
You've installed @theokit/sdk and have a provider API key. The cheapest path is OpenRouter — sign up at openrouter.ai, copy a key, and:
export OPENROUTER_API_KEY="sk-or-v1-..."The SDK auto-detects which provider env var you set. No extra config.
Write your first agent
Save this as hello.ts:
import { Agent } from "@theokit/sdk";
const agent = await Agent.create({
apiKey: process.env.OPENROUTER_API_KEY,
model: { id: "openai/gpt-4o-mini" },
});
const run = await agent.send("What is 2+2?");
const result = await run.wait();
console.log(result.result);
await agent.dispose();Run it
npx tsx hello.tsYou should see something like:
2 + 2 = 4That's it. 7 lines, no scaffolding, no config file.
What just happened
Agent.create()spins up a local agent loop bound to your API key + a model id.agent.send(prompt)returns aRunhandle — the agent is processing in the background.run.wait()blocks until the agent is done. The result has.status,.result,.messages, etc.agent.dispose()releases any file handles, MCP processes, or background tasks. Always dispose.