Flue is a TypeScript framework for building autonomous agents, designed around a built-in agent harness. It's like Claude Code, but headless and programmable. No TUI, no GUI, just TypeScript. The agents you build act autonomously to solve problems and complete tasks, and most of the logic lives in Markdown: skills, context, and AGENTS.md. Write once, then deploy anywhere.
In this guide you will build and deploy a Flue agent to Vercel, connect it to a Vercel Sandbox MicroVM for isolated code execution, and route all model traffic through Vercel AI Gateway for spend tracking, failover, and observability.
A coding agent exposed over HTTP. It receives a repo URL and a prompt, clones the repo into an isolated Sandbox MicroVM with a real Linux shell, and uses an LLM to explore and work on the codebase. All LLM calls are routed through AI Gateway using a single provider/model string, with spend caps and rate limits available from the Vercel dashboard.
- Node.js 22+
- Vercel CLI (
pnpm add -g vercel) - A Vercel project with AI Gateway enabled
pnpminstalled
You should already have a Flue project that builds and runs. If you don't, scaffold one first:
This gives you a project with the following layout:
Connect your Flue project to Vercel and pull a development OIDC token:
This creates a .env.local file with a VERCEL_OIDC_TOKEN, a short-lived JWT that authenticates requests to both AI Gateway and Sandbox. Both SDKs read it from the environment automatically. No provider API keys or manual wiring needed.
The token expires after 12 hours. Run vercel env pull again if you see auth errors. On Vercel deployments, token refresh is automatic.
Flue ships a first-party Vercel Sandbox connector. Install it with flue add and pipe the instructions to your coding agent:
This writes a .flue/connectors/vercel.ts adapter into your project. Any coding agent works here:
Then install the Sandbox SDK:
Create .flue/agents/coder.ts. Three things differ from a default Hello World agent: you import the Sandbox connector, create a MicroVM, and configure AI Gateway as the model provider.
The Sandbox boots a real Linux MicroVM with git, node, npm, and a full shell. resources: { vcpus: 2 } gives it 4 GB of RAM (2 GB per vCPU). The source option clones the target repo on creation.
Next, initialize the Flue agent with the sandbox and AI Gateway routing:
The model string uses AI Gateway's provider/model format. You can swap to any model in the model catalog by changing that string. The providers block routes all Anthropic traffic through AI Gateway's endpoint, authenticated with your OIDC token. No ANTHROPIC_API_KEY needed.
Start the Flue dev server, pointing it at your .env.local:
Flue defaults to port 3583. Test the agent with curl:
The response streams back via SSE. Reuse the same session ID (session-1) to continue the conversation. Use a new ID to start fresh.
Roles give your agent persistent instructions without polluting the user prompt. Create .flue/roles/coder.md:
Then pass the role in your prompt call:
Roles can be set at the agent, session, or call level. Call-level roles (like above) take the highest precedence.
Use session.task() to run a focused subtask in a detached session. Tasks share the same sandbox and filesystem but get their own message history. This is useful for parallel exploration before a main prompt:
The LLM can also spawn tasks on its own during prompt() and skill() calls, delegating parallel research or exploration work without you writing the orchestration.
The first Sandbox creation takes a few seconds while the MicroVM boots and clones the repo. For repeat sessions against the same repo, snapshots eliminate that wait:
Calling snapshot() saves the entire MicroVM state, including cloned files and installed dependencies. Subsequent sessions boot from the snapshot in ~100ms:
Store the snapshot ID per repo and reuse it across agent invocations.
Common knobs you can set on Sandbox.create():
runtime:'node24','node22', or'python3.13'.resources:{ vcpus: 1 }through{ vcpus: 8 }. Each vCPU comes with 2 GB of RAM.ports: up to 4 exposed ports, each gets a public URL viasandbox.domain(port).timeout: max lifetime. Up to 5 hours on Pro/Enterprise, 45 minutes on Hobby.networkPolicy: restrict outbound access to specific domains or CIDRs if your agent should not reach arbitrary hosts.
For anything beyond these, treat the Sandbox SDK reference as the source of truth.
Build the deployable artifact and deploy:
On Vercel, the OIDC token auto-refreshes. AI Gateway spend caps, rate limits, and usage analytics apply to all production traffic from the dashboard.
- Browse the AI Gateway model catalog to try different models by changing the
provider/modelstring. - Configure failover and caching in AI Gateway for production resilience.
- Explore Sandbox network policies to lock down outbound access.
- OIDC token expired locally? Run
vercel env pullagain to get a fresh one. - Sandbox provisioning slow? Use snapshots to skip boot and clone time.
- Model not found? Check the model catalog for the correct
provider/modelslug. Version numbers use dots, not hyphens (e.g.claude-sonnet-4.6, notclaude-sonnet-4-6). - Sandbox questions: Vercel Sandbox docs, SDK reference.
- AI Gateway questions: AI Gateway docs.
- Flue questions: withastro/flue on GitHub.