Agents
Define an AI agent in one file, give it files and tools, and reach it from chat, Slack, or GitHub.
Deploys on
- Node
- Docker
- Cloudflare
- Vercel
- Netlify
- Deno
Start here
Section titled "Start here"- First Agent: run an Agent with no API key.
- Learning path: go from your first run to models, tools, and a full app.
- Build a chat app: connect a model, a streaming route, and a Vue chat UI.
For a single model call without tools, such as a summary or fields read from text, you do not need an Agent. Call ask(prompt, { model, schema }) from AI Gateways to get data checked against your schema.
Define and run
Section titled "Define and run"An Agent Definition picks a Driver to do the work, and an Invocation runs it with one input. This example needs no model or credentials:
import { defineAgent, runAgent } from 'vite-hub/agent'
const greeting = defineAgent({
runtime: false,
driver: {
run({ prompt }) {
const name = typeof prompt === 'string' ? prompt : 'friend'
return { text: `Hello, ${name}!` }
},
},
})
const [error, result] = await runAgent(greeting, { prompt: 'Ada' })
if (error) throw error
console.log(result.text) // 'Hello, Ada!'runAgent() returns an [error, result] tuple. See Invocations for model output, provider Drivers, and streaming.
Learn in order
Section titled "Learn in order"- Define an Agent and choose its Driver.
- Run or stream an Invocation.
- Write instructions and attach tools through Capabilities.
- Select Chat History and add Workspace context.
- Connect a Channel for messages from another service or web chat.
- Inspect events, test contracts, and evaluate model behavior.
Then share configuration with presets and inheritance and keep run records with Invocation storage. Ready-made presets give full workflows, each with its own setup.
Choose what does the work
Run an AI model, Codex, Claude Code, or your own function. Your routes call the Agent the same way.
Give it only the tools you choose
An Agent cannot use a server feature until you add a tool for it. Built-in tools cover web search, memory, and MCP servers.
Let it read your files
Give it a folder from your project or GitHub. You choose whether the Agent can only read or also write.
Talk to it where people already are
Connect web chat, Slack, Discord, Telegram, Teams, GitHub, or an HTTP route.