---
agent:
  instructions: "Use this search API to find what Blueping's public pages say, with keywords or a question, instead of crawling them one by one. Results are returned in Markdown, best first, each with its link."
  endpoint: "https://blueping.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

> The index of these docs for agents is at https://blueping.dev/llms.txt

# Give your Vercel AI SDK agent its own email address.

Each call becomes a tool, so the model makes an inbox, waits for its code and replies, in one run.

agent.js:

```javascript
import { tool } from "ai";
import { z } from "zod";
import { createInbox } from "./blueping-tools.js";

const create_inbox = tool({
  description: "Create an email inbox that receives at once.",
  inputSchema: z.object({ username: z.string() }),
  execute: ({ username }) => createInbox(username),
});
```

The calls it wraps are in blueping-tools.js, in the setup below.

[Get an address](https://blueping.dev/signup.md) · [**Agents** /integrations/vercel-ai-sdk.md](https://blueping.dev/integrations/vercel-ai-sdk.md)

Blueping makes email inboxes for AI agents: one API call gives an agent its own address, with verification codes pulled out and every sender checked.

## Give the AI SDK its email tools in two files

Each Blueping call becomes an AI SDK `tool()` with a zod `inputSchema`, and `generateText` lets the model call them over several steps. The agent gets an address of its own and reads its mail as JSON.

### 1. The five calls over fetch

`blueping-tools.js` exports the calls the tools wrap. Each one is a `fetch` to the API with `BLUEPING_API_KEY`, so the same file runs in a route handler, a script or a worker.

blueping-tools.js:

```javascript
// blueping-tools.js: an inbox for your agent, in five functions. Node.js 18+, no dependency.
const API = "https://blueping.dev/v1";

async function call(method, path, body) {
  const response = await fetch(API + path, {
    method,
    headers: { Authorization: `Bearer ${process.env.BLUEPING_API_KEY}`, "Content-Type": "application/json" },
    body: body ? JSON.stringify(body) : undefined,
  });
  return response.json(); // a refusal is { error: { code, message, next_action } }
}

export const createInbox = (username) => call("POST", "/inboxes", { username, client_id: username });
export const waitForCode = (inboxId, sender = "") =>
  call("GET", `/inboxes/${inboxId}/code?wait=50${sender ? `&from=${encodeURIComponent(sender)}` : ""}`);
export const readInbox = (inboxId) => call("GET", `/inboxes/${inboxId}/messages?limit=10`);
export const sendEmail = (inboxId, to, subject, text) => call("POST", `/inboxes/${inboxId}/messages`, { to, subject, text });
export const reply = (messageId, text) => call("POST", `/messages/${messageId}/reply`, { text });
```

### 2. The tools and the call

`isStepCount(5)` lets the model make an inbox, wait for its code and answer in one run.

agent.js:

```javascript
import { generateText, isStepCount, tool } from "ai";
import { z } from "zod";
import { createInbox, reply, waitForCode } from "./blueping-tools.js";

const { text } = await generateText({
  model: "anthropic/claude-sonnet-5.5",
  tools: {
    create_inbox: tool({ description: "Create an email inbox that receives at once.", inputSchema: z.object({ username: z.string() }), execute: ({ username }) => createInbox(username) }),
    wait_for_code: tool({ description: "Wait for the next verification code or link.", inputSchema: z.object({ inboxId: z.string(), sender: z.string().optional() }), execute: ({ inboxId, sender }) => waitForCode(inboxId, sender) }),
    reply: tool({ description: "Answer an email in its thread.", inputSchema: z.object({ messageId: z.string(), text: z.string() }), execute: ({ messageId, text }) => reply(messageId, text) }),
  },
  stopWhen: isStepCount(5),
  prompt: "Make an inbox called selbywick-trial and tell me its address.",
});
console.log(text);
```

Checked against [AI SDK docs, tools and tool calling](https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling) on November 22, 2026.

## What an AI SDK agent does with its own inbox

### A route that answers support mail

A Next.js route receives `email.received`, `generateText` drafts the answer with your docs, and `reply` sends it in the thread.

### Streaming the steps to your UI

With `streamText`, each tool call shows in your interface as it happens: the inbox made, the code read.

### A run that ends once the answer is sent

Put `hasToolCall("reply")` in `stopWhen` next to the step limit, and the loop stops the moment the reply leaves, with no extra turn for the model.

## Before you connect the AI SDK

- The tools return JSON, so the model reads a refusal's `next_action` as it reads a success.
- An `onStepEnd` callback hands you each step's tool calls and results, so your logs keep which inbox was made and which code was read.

### Does it run on the Edge runtime?

Yes: the calls use `fetch` only, and the key comes from your environment.

### Can the AI SDK load the MCP server's tools instead?

Yes: its MCP client reads the tools of the hosted server at `https://blueping.dev/mcp`, with your key in the request headers. The functions above keep the tool list to the three calls this agent needs.

## Build more with the AI SDK

- [**A support inbox** Customers write to an address your agent owns. It answers in the thread and leaves refunds and attacks to your team.](https://blueping.dev/use-cases/support-inbox.md)
- [**Verification codes and sign-ups** The agent signs up to a service with an address of its own and reads the code or the magic link in one call.](https://blueping.dev/use-cases/verification-codes.md)
- [**Orders, shipping and returns** The agent matches each email to an order, answers with its status, sends return labels and reads carrier notices.](https://blueping.dev/use-cases/orders-and-returns.md)
- [**CrewAI** @tool functions for each agent of the crew.](https://blueping.dev/integrations/crewai.md)
- [**Mastra** createTool definitions given to a Mastra Agent.](https://blueping.dev/integrations/mastra.md)
- [**LlamaIndex** Plain functions given to a FunctionAgent.](https://blueping.dev/integrations/llamaindex.md)

[All integrations](https://blueping.dev/integrations.md) · [The quickstart](https://blueping.dev/docs.md) · [API reference](https://blueping.dev/docs/api.md) · [Every MCP client](https://blueping.dev/agents.md)
