# Cartesia

MillionShort search for a Cartesia voice agent, as a webhook tool that calls the API.

Recipe · Playground and API · Nothing of ours to install · Checked 2026-11-19

> **For agents.** Read the API key from the `MILLIONSHORT_API_KEY` environment variable. Never print it; where a client needs it in a settings file, use a file that is not committed.
> The MCP address is https://mcp.millionshort.com/mcp (streamable HTTP; send `Authorization: Bearer <key>`, or no header for the no-key mode).
> On `INSUFFICIENT_CREDITS` stop and ask a person; on `RATE_LIMITED` or `CAPACITY` wait the `Retry-After` seconds, then retry once.
> Set-up steps written for agents: https://millionshort.com/docs/auth.md. Every integration: https://millionshort.com/docs/integrations.md.

Cartesia's agents have three kinds of tools: system tools, webhook tools and client tools. We found no way in Cartesia's agent documentation to connect an agent to an outside MCP server, so this page uses a webhook tool: when the model calls it, Cartesia sends `POST /v1/search` to our API and gives the response body to the model.

Spoken answers work best with few results: the tool below fixes `num_results` at 3 and `max_highlights` at 1, so the model reads short passages rather than long text. Each search also adds a little latency to the turn it runs in.

## 1. Install

Nothing to install. You need a MillionShort key from the [dashboard](https://millionshort.com/app/) and a Cartesia API key.

## 2. Create the webhook tool

Create the tool with Cartesia's API: send `POST https://api.cartesia.ai/v1/agents/tools` with your Cartesia API key as a bearer token in `Authorization`, the header `Cartesia-Version: 2026-08-14`, and this JSON body:

```json
{
  "type": "webhook",
  "name": "millionshort_search",
  "description": "Searches the web for current or niche information. Use it when the caller asks about recent events or facts you do not know.",
  "pre_tool_speech": "auto",
  "execution_mode": "immediate",
  "response_timeout_secs": 20,
  "api_schema": {
    "url": "https://api.millionshort.com/v1/search",
    "method": "POST",
    "request_body_schema": {
      "type": "object",
      "properties": {
        "query": { "type": "string", "description": "What to search for." },
        "num_results": { "type": "integer", "constant_value": 3 },
        "max_highlights": { "type": "integer", "constant_value": 1 },
        "remove_top_sites": { "type": "integer", "constant_value": 1000 }
      },
      "required": ["query"]
    },
    "authentication": {
      "mode": "bearer",
      "token": { "type": "secret", "secret_value": "ms-YOUR_API_KEY" }
    }
  }
}
```

`authentication` with `mode` `bearer` sends `Authorization: Bearer ms-YOUR_API_KEY`; Cartesia stores the key as a secret and never returns it. Do not also set `Authorization` in `request_headers`. The model fills in `query` only: values set with `constant_value` are hidden from it.

In the Playground, the same fields are on the **Tools** page: **Add tool**, then **Webhook**, gives the Create Webhook form with the tool name, description, method, URL, authentication and execution settings.

## 3. Give the tool to an agent

Add the tool's ID to the agent's `config.tools` as `{ "id": "<tool_id>" }`. An update to `config.tools` replaces the whole list, so include the tools the agent already has. An agent can have up to 64 tools.

Then say when to search in the agent's instructions, and how to answer:

> Use the millionshort_search tool for anything recent, niche, or that needs a source. Answer in two or three short sentences and name the site you used.

## 4. Check it works

Place a test call from the Playground and ask a question that needs the web. The answer should name pages it found. If the request fails, Cartesia gives the model an error result and the conversation goes on.

A search that worked returns `data.results`, each with a `title`, a `url` and `highlights`, and `usage.credits`: what it cost.

## Settings

| Field | Value | Meaning |
|---|---|---|
| `api_schema.url` | `https://api.millionshort.com/v1/search` | Our search endpoint. Cartesia does not follow redirects, so use this address as written |
| `api_schema.authentication` | `bearer`, with the key as a secret | Sends `Authorization: Bearer ms-...` |
| `num_results`, `max_highlights` | `constant_value` 3 and 1 | Few results with one short passage each, for a spoken answer |
| `remove_top_sites` | `constant_value` 1000 | Leaves out the 1,000 most popular sites. Set it to 0 to keep them |
| `pre_tool_speech` | `auto` | Lets the agent decide whether to say something before it searches. `force` always asks it to |
| `execution_mode` | `immediate` | Runs in the current turn. `async` lets the turn finish while the search runs |
| `response_timeout_secs` | 20 | How long Cartesia waits for our answer (1 to 120) |

## Costs and limits

A tool call costs what the API call behind it costs: 1 credit per source searched for the first 10 results, 1 credit for a domain lookup, nothing for the list of sources, the price of the endpoint for the other tools, and nothing at all in the no-key mode. An agent that loops can make many calls: give it a step limit, and ask for fewer results when a few will do. [Credits and limits](https://millionshort.com/docs/credits-and-limits) has the numbers.

Cartesia passes at most 16 KiB of a response body to the model and cuts the rest. Three results with one highlight each stay small.

## When it fails

| What you see | Why | Fix |
|---|---|---|
| `401 AUTH_MISSING_KEY` or `AUTH_INVALID_KEY` | The key is missing or wrong | Set `MILLIONSHORT_API_KEY`; keys start with `ms-` |
| `400 INVALID_PARAM` | A field name or value the API does not take | The `message` names the field; the [search reference](https://millionshort.com/docs/search/parameters) lists them all |
| `429 RATE_LIMITED` or `CAPACITY` | Too many calls a minute, or no free capacity right now | Wait the `Retry-After` seconds, then retry |
| `429 INSUFFICIENT_CREDITS` | The plan's credits are used up | Stop and add credits; do not retry |
| The model gets an error result and says it could not search | Our API returned an error, did not answer within `response_timeout_secs`, or could not be reached; Cartesia does not retry a `POST` | Check the key and the URL, and that the tool sends no `Authorization` in `request_headers` |
| The result ends with "[cut off: the response was longer than this tool returns]" | The response was over 16 KiB | Keep `num_results` at 3 and `max_highlights` at 1 |
| The agent never calls the tool | The description or the instructions do not say when to | Say in both when to search |

## Related

- [ElevenLabs Agents](https://millionshort.com/docs/integrations/elevenlabs), [Vapi](https://millionshort.com/docs/integrations/vapi) and [Pipecat](https://millionshort.com/docs/integrations/pipecat): voice agents that connect to the MCP server.
- [Search reference](https://millionshort.com/docs/search/parameters): every field of `POST /v1/search`.
- [Filters for agents](https://millionshort.com/docs/search/filters) and [Agent tool use](https://millionshort.com/docs/search/guides/agent-tool-use).
- Cartesia's own documentation, read on 2026-11-19: [Tools](https://docs.cartesia.ai/agents/tools), [Webhook tools](https://docs.cartesia.ai/agents/webhook-tools), [Create a tool](https://docs.cartesia.ai/api-reference/agents/tools/create).
