# Build your first agent

Create an agent from nothing and get its first reply, in code or in Studio.

## Before you start

You need a Veryfront account. [Sign in](/sign-in) or create one. The Free plan includes 50 credits a month.

## Create your first agent

**Studio**

1. Open **Agents**.
2. Click **New agent**.
3. Enter "Tip helper" as the **Name**.
4. Click **Create agent**. Studio makes a project for the agent and opens a chat with it.
5. In the project, open **Agents**.
6. Click Tip helper.
7. Click **Edit**.
8. Replace the **Instructions** with "Work out tips and splits for restaurant bills. Show the arithmetic in one line."
9. Click **Save**. The agent's page now shows them.
10. Open **Chat**. It opens a chat with Tip helper.
11. Write "What's an 18% tip on £84.50?" in the message box.
12. Press Enter. You should now see the agent show the sum and reply £15.21.

**Code**

1. Create a project from the AI Agent template. It needs Node.js 22.3 or later:

```bash
npm create veryfront@latest my-agent -- --template ai-agent
```

2. Answer **Use Veryfront Cloud?**:
   * **Yes**: choose **Create a new cloud project**, then sign in when the browser opens.
   * **No**: [set your provider's key](/docs/code/guides/providers.md).

3. Start it:

```bash
cd my-agent
npm run dev
```

4. Open the address it prints, usually [localhost:3000](http://localhost:3000).
5. Ask "What's an 18% tip on £84.50?". You should now see the agent call its calculator tool and reply £15.21.

### Try it in a sandbox

```playground
step: Create the agent | npm create -y veryfront@latest my-agent -- --template ai-agent --yes
step: Start it | cd my-agent && npm run dev
agent: assistant
ask: What's an 18% tip on £84.50?
tool: calculator
expect: 15.21
```

## Without a browser

`Use Veryfront Cloud?` only appears in an interactive terminal. Without one, set `OPENAI_API_KEY` before `npm run dev`; the agent then uses `openai/gpt-5-nano`. The sandbox card signs in to Veryfront Cloud for you, so it needs neither.

Check the reply without the UI. The dev server checks CSRF on every POST, so send a matching `__Host-vf_csrf` cookie and `x-csrf-token` header. Any value works locally if both match.

```bash
curl -N localhost:3000/api/ag-ui -H 'content-type: application/json' \
  -H 'Cookie: __Host-vf_csrf=local' -H 'x-csrf-token: local' \
  -d '{"messages":[{"id":"1","role":"user","parts":[{"type":"text","text":"Hi"}]}]}'
```

It worked when the stream contains `event: TextMessageContent`.

## With MCP

These calls build the Studio tab's Tip helper, which has no tools.

1. Call `veryfront__create_project` with `"name": "Tip helper"`. Note its `slug`.
2. Call `veryfront__create_agent`. The instructions go in `system`:

```json
{
  "project_reference": "<slug>",
  "id": "tip-helper",
  "name": "Tip helper",
  "system": "Work out tips and splits for restaurant bills. Show the arithmetic in one line.",
  "source_target_kind": "project"
}
```

3. Call `veryfront__create_conversation` with the question as its first message:

```json
{
  "project_reference": "<slug>",
  "type": "chat",
  "title": "Tip on £84.50",
  "initial_message": {
    "parts": [{ "type": "text", "text": "What's an 18% tip on £84.50?" }]
  }
}
```

4. Call `veryfront__create_run`. Take `project_id`, `id` (as `conversation_id`) and `initial_message_id` from the conversation, and pass the same question as the run's input:

```json
{
  "input": {
    "project_id": "<project_id>",
    "conversation_id": "<id>",
    "target": { "type": "agent", "id": "tip-helper" },
    "input": {
      "agent_id": "tip-helper",
      "messages": [{ "id": "<initial_message_id>", "role": "user", "parts": [{ "type": "text", "text": "What's an 18% tip on £84.50?" }] }],
      "tools": [],
      "context": []
    },
    "config": {
      "agent_admission": { "mode": "project", "input_message_id": "<initial_message_id>", "source_target_kind": "project" }
    },
    "execution": { "runtime": { "type": "main_branch" } }
  }
}
```

5. Call `veryfront__get_run` with the run's `id` as `run_id` until its `status` is `completed`.
6. Call `veryfront__list_conversation_messages` with the conversation's `id` as `conversation_id`. It worked when an `assistant` message says £15.21.

## Next steps

* [Add a tool](/docs/agents/tools.md)
* [Add knowledge](/docs/agents/knowledge.md)
