OneCompiler
AI Agent

AI Agent

AI/ML

A working AI agent you can run in your browser. It's an Express server built on the Vercel AI SDK and Google's Gemini models that can call tools, take several steps and stream its answer back. Add your own API key, run it and ask it something.

What's included

Tool-calling agent

An agent built on the Vercel AI SDK that can call tools and run up to a few steps to answer, with the loop already wired up.

Real VS Code

The full cloud editor with an integrated terminal and extensions, so you can edit the agent and its tools in one place.

Streaming HTTP endpoint

A /api/chat endpoint that streams the agent's response, plus a chat UI served at the root on port 3000.

Git ready

Clone, commit and push from the terminal, or connect a GitHub repo whenever you want.

Tech stack

Node.jsExpressTypeScriptVercel AI SDKGoogle GeminiZod

What is the AI Agent template?

An AI agent is a program that uses a language model to decide what to do next, often by calling tools and chaining several steps together rather than answering in one shot. This template is a small, working example of that pattern, built as an Express server on the Vercel AI SDK with Google's Gemini models behind it.

Out of the box it acts as an activity planner. It comes with two example tools, one for weather and one for activity suggestions, and the model can call them across a handful of steps before it replies. The code is compact enough to read end to end, so it's a clear base for building your own agents.

What's inside this workspace

The server is src/app.ts. It exposes a POST /api/chat endpoint that runs the agent with streamText from the Vercel AI SDK, streams the result back as Server-Sent Events, and serves a chat UI from public/. A system prompt sets it up as a helpful activity planner.

The tools live in src/tools.ts, defined with Zod input schemas. There's a weather tool and an activity tool, and the agent is allowed to take several steps so it can call a tool, read the result and decide what to do next. Add your own tools the same way.

Running it and adding your key

You supply your own Gemini API key. Create one for free in Google AI Studio, copy env.example to .env, and set GOOGLE_GENERATIVE_AI_API_KEY to your key.

Then run npm run dev. The server starts on port 3000 and Studio opens the chat UI in a browser preview. You can also hit the endpoint directly from the terminal, for example: curl http://localhost:3000/api/chat -H 'Content-Type: application/json' --data-raw '{"message":"What is the weather in Tokyo?"}'.

What you can build with it

Swap the example tools for real ones and you have a foundation for agents that look things up, hit your own APIs, query a database or take actions on a user's behalf. Because the streaming and multi-step loop are already in place, you mostly write tools and shape the system prompt.

Frequently asked questions

Do I need an API key?

Yes. You bring your own Gemini API key. Create one for free in Google AI Studio, then copy env.example to .env and set GOOGLE_GENERATIVE_AI_API_KEY. Nothing calls the model until you add your key.

What makes this an agent rather than a chatbot?

It can call tools and run several steps. The model decides whether to use a tool, reads the result and can keep going before answering. The template ships with example weather and activity tools to show the pattern.

How do I add my own tools?

Define a tool in src/tools.ts with a Zod input schema and an execute function, then register it in the streamText call in src/app.ts. The agent can then choose to call it.

Where does it run and how do I call it?

On port 3000. Studio opens the chat UI in a browser preview after npm run dev, and you can also POST to /api/chat from the terminal or any REST client to get a streamed response.

Which model does it use?

It runs on one of Google's fast Gemini models through the Vercel AI SDK's Google provider. You can switch the model in src/app.ts.

Is it free?

This template runs on a paid plan. Templates that are free are marked as such on the Studio page, and you can upgrade from the pricing page. Your Gemini API usage is billed separately by Google under their terms.

Related templates

AI Agent online Studio — cloud LLM agent workspace | OneCompiler