> ## Documentation Index
> Fetch the complete documentation index at: https://www.agent37.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Managed services

> Use Agent37's LLM router at OpenRouter cost with no markup, Brave Search over HTTP, and Composio and Perflo over MCP. One instance token spends workspace credit within its budget.

Agent37 provides four managed services for stock templates and custom images. You do not need
your own provider keys or accounts.

> [!NOTE]
>
> These managed services are intended only for agents and applications running inside Agent37-hosted instances. Requests from outside this hosting environment may be denied.

| Service | Interface | Endpoint |
| - | - | - |
| LLM router | OpenAI-compatible HTTP API | `https://api.agent37.com/llm/v1` |
| Brave Search | HTTP API, JSON requests | `https://api.agent37.com/search/brave` |
| Composio app integrations | MCP, streamable HTTP | `https://api.agent37.com/mcp/composio` |
| Perflo paid tools | MCP, streamable HTTP | `https://api.agent37.com/mcp/perflo` |

**LLM and Brave are APIs; Composio and Perflo are MCP servers.** Configure the LLM URL as your
model client's base URL. Register Composio and Perflo with your MCP client.

## Credentials in your instance

Every Agent37 instance boots with credentials already in its environment. Your image does not
receive them from you, does not store them, and does not need to ask for them:

| Variable | Value |
| - | - |
| `AGENT37_MANAGED_TOKEN` | A per-instance token |
| `AGENT37_LLM_PROXY_URL` | `https://api.agent37.com/llm/v1` |
| `AGENT37_BRAVE_PROXY_URL` | `https://api.agent37.com/search/brave` |
| `AGENT37_COMPOSIO_MCP_URL` | `https://api.agent37.com/mcp/composio` |
| `AGENT37_PERFLO_MCP_URL` | `https://api.agent37.com/mcp/perflo` |
| `AGENT37_INSTANCE_ID` | This instance's id |

That token opens all four services. **This applies to any image**, including one you built
yourself from scratch: the platform injects these at container create, not the image.

Those six are the contract, alongside the three switches in [Not using them](#not-using-them). A
container's environment carries other `AGENT37_`-prefixed variables that are runtime internals;
they change without notice, so build against the six above.

### Spend workspace credit with the starter token

The **starter token** is the instance credential, `AGENT37_MANAGED_TOKEN`. Accounts created
before November 20, 2026 also carry it as `AGENT37_STARTER_TOKEN` and `OPENCLAW_STARTER_TOKEN`,
older aliases for the same value that newer accounts do not get. Send it as
`Authorization: Bearer` on each managed request, as the examples below show. Read it from the
instance environment on every boot.

To let an instance spend:

1. Fund the workspace [wallet](https://www.agent37.com/docs/agents-api/billing.md), or use its available signup credit.
2. Grant the instance [budget headroom](https://www.agent37.com/docs/agents-api/budgets.md), which defaults to zero. At create,
   `"budget": { "credit_micros": 1000000 }` grants \$1 of one-time headroom. For an existing
   instance, use the request below.
3. Call a managed service with the instance token. Agent37 charges the workspace wallet and
   counts the usage against that instance's budget automatically.

Run this from your backend with your workspace API key to grant an existing instance \$1 of
one-time headroom. Set `INSTANCE_ID` to the id returned when you created the instance:

```bash theme={null}
curl -sS -X POST "https://api.agent37.com/v1/instances/$INSTANCE_ID/budget/top-up" \
  -H "Authorization: Bearer $AGENT37_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "amount_micros": 1000000, "idempotency_key": "managed-services-setup-1" }'
```

The `sk_live_...` workspace key manages budgets; the instance token authorizes managed-service
usage. The token does not contain money, and granting headroom does not add funds to the wallet.
Both wallet funds and instance headroom must be available for a paid call to succeed.

Run the service examples below **inside the instance**, where the environment variables are set.

```text title="Paste this into your coding agent" wrap theme={null}
Read https://www.agent37.com/docs/llms-full.txt.
I want to run my own agent in a custom image, using the managed model and Composio MCP server every instance gets from its environment, with no provider keys.
Have the entrypoint read AGENT37_LLM_PROXY_URL, AGENT37_COMPOSIO_MCP_URL, and AGENT37_MANAGED_TOKEN from the environment on every boot and configure my agent from them, then publish the image as a template and create an instance from it with a budget.
Done when my agent, run over exec, answers a question on the managed model and lists its Composio tools.
My key is in AGENT37_API_KEY.
```

## LLM router

Agent37's LLM router uses OpenRouter and passes through the reported inference cost with **no
Agent37 markup**. Choose any supported paid model from its catalog; you do not need your own
OpenRouter account or API key. The cost draws on the same workspace wallet as the other services.

Set an OpenAI-compatible client's base URL to `$AGENT37_LLM_PROXY_URL` and its API key to
`$AGENT37_MANAGED_TOKEN`. The router exposes `GET /llm/v1/models` and
`POST /llm/v1/chat/completions`. It is a plain HTTP API, not an MCP server.

List the available models:

```bash theme={null}
curl -sS "$AGENT37_LLM_PROXY_URL/models" \
  -H "Authorization: Bearer $AGENT37_MANAGED_TOKEN"
```

Send a completion:

```bash theme={null}
curl -sS "$AGENT37_LLM_PROXY_URL/chat/completions" \
  -H "Authorization: Bearer $AGENT37_MANAGED_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "model": "default", "messages": [{"role":"user","content":"hello"}] }'
```

`"default"` is a fast, low-cost model we pick and keep current. To choose another model, replace
`"default"` with an exact `data[].id` from the model list, using its OpenRouter `provider/model`
name. Listing models is free. Set `"stream": true` for streaming completions. Free models and
models without tool support are rejected, because agents need tools.

This model list belongs to the router. The [Agent API model list](https://www.agent37.com/docs/agents-api/models.md) on your
instance's URL describes the models configured in that instance's agent harness.

## Web search

Call Brave Search with `POST $AGENT37_BRAVE_PROXY_URL`, the same bearer token, and a JSON body.
It is an HTTP API, not an MCP server. Each call costs \$0.005 (5,000 micros).

```bash theme={null}
curl -sS "$AGENT37_BRAVE_PROXY_URL" \
  -H "Authorization: Bearer $AGENT37_MANAGED_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "query": "Agent37 documentation", "count": 3 }'
```

`query` is required. `count` is optional and is clamped to 1 through 20. Optional string fields
are `country`, `searchLang`, `uiLang`, `safesearch`, and `freshness`. The response is Brave's JSON
search result, with web results under `web.results`.

## Integrations

A [Composio](https://composio.dev) MCP server, scoped to this instance's own entity, at
`$AGENT37_COMPOSIO_MCP_URL` with the same bearer token. It speaks streamable HTTP.

```bash theme={null}
curl -sS "$AGENT37_COMPOSIO_MCP_URL" \
  -H "Authorization: Bearer $AGENT37_MANAGED_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

Some MCP clients append `/mcp` to whatever URL you give them. That lands on
`https://api.agent37.com/mcp/composio/mcp`, which is the same server, so register the URL as-is
either way.

It exposes a handful of meta-tools rather than hundreds of individual ones, so it costs very
little context: the agent searches the catalog for what it needs, then executes it. The tool
names and their behavior are Composio's surface, documented in
[Composio's meta-tools reference](https://docs.composio.dev/reference/meta-tools/search_tools).
Billing is ours and is simple: discovery (searching tools, fetching schemas) is free; executing
tools and managing connections bills per tool call, with a batch execute capped at 50 calls.

> [!TIP]
>
> The connection-management meta-tool lets the agent start its own OAuth connections from inside
> the instance. Driving [the integrations API](https://www.agent37.com/docs/agents-api/integrations.md) from your backend is the
> alternative, not the prerequisite.

> [!WARNING]
>
> `POST` and `DELETE` only. A `GET` returns `405` by design, because proxying the optional
> server-push stream would hold one open connection per instance. Well-behaved MCP clients treat
> `405` as "this server has no server-push stream" and carry on, but some probe the older SSE
> transport and report the server as failed. If your client offers an explicit transport
> setting, set it to streamable HTTP.

## Paid tools

A pay-per-call MCP server at `$AGENT37_PERFLO_MCP_URL`, same bearer token, streamable HTTP. It
fronts [Perflo](https://perflo.ai)'s catalog of roughly 490 vendors: web scrapes, people and
company lookups, enrichment, generation, phone numbers and calls. The agent buys one call at a
time, typically for a cent. There are no vendor accounts to create, no keys to hold, and no
subscriptions.

```bash theme={null}
curl -sS "$AGENT37_PERFLO_MCP_URL" \
  -H "Authorization: Bearer $AGENT37_MANAGED_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

Four tools:

| Tool | What it does |
| - | - |
| `list_services` | The catalog, with each vendor's slug and exact price. Free to call |
| `spend` | Describe the job and let Perflo pick the vendor and pay. Priced after the fact |
| `pay` | Buy from one vendor you named, with a `maxCharge` checked before any money moves |
| `get_task_result` | Collect what a call bought |

Discovery is free; `spend` and `pay` are the two that cost anything, and each is charged at the
exact amount Perflo reports, with no markup. The spend draws on the instance
[budget](https://www.agent37.com/docs/agents-api/budgets.md) and then the workspace wallet, like every managed service, and lands
under `perflo` in `GET /v1/instances/{id}/usage` and `GET /v1/usage`.

A `spend` answers once its charge is final, which is usually about ten seconds, so the agent sees
one ordinary tool call rather than a job to poll. A call still running after 240 seconds comes back
as a task id instead, to collect with `get_task_result` when it finishes.

> [!NOTE]
>
> Two categories are switched off on purpose, gift cards and one paid-social group, because an
> agent moving that kind of money on your balance is not what this is for. With those gone the most
> expensive single call in the catalog is about \$3.50, and a refused call costs nothing.

The `agent37-hermes` and `agent37-openclaw` templates register this server themselves at boot from
the environment, so their agents simply have the tools. To keep an instance's agent out of paid
tools entirely, switch them off at create ([Not using them](#not-using-them)). A custom image
registers the server like any other MCP server:

```json mcp.json theme={null}
{
  "mcpServers": {
    "perflo": {
      "type": "streamable-http",
      "url": "https://api.agent37.com/mcp/perflo",
      "headers": { "Authorization": "Bearer ${AGENT37_MANAGED_TOKEN}" }
    }
  }
}
```

New instances have the tools already. An instance created before 2026-09-27 needs one
`POST /v1/instances/{id}/update`, which pulls the current image, and then it does too.

## Wiring an agent to both

Two config blocks, using [pi](https://pi.dev) as the example. Neither contains a credential;
both reference the environment variable instead:

```json models.json theme={null}
{
  "providers": {
    "agent37": {
      "baseUrl": "https://api.agent37.com/llm/v1",
      "apiKey": "$AGENT37_MANAGED_TOKEN",
      "api": "openai-completions",
      "models": [{ "id": "default", "name": "Default", "contextWindow": 128000, "maxTokens": 8192 }]
    }
  }
}
```

```json mcp.json theme={null}
{
  "mcpServers": {
    "composio": {
      "type": "streamable-http",
      "url": "https://api.agent37.com/mcp/composio",
      "headers": { "Authorization": "Bearer ${AGENT37_MANAGED_TOKEN}" }
    }
  }
}
```

A complete, runnable image doing exactly this lives at
[agent37-platform/pi-agent-image](https://github.com/agent37-platform/pi-agent-image). It stays here as the worked
example of the pattern; Pi itself no longer needs it, since [`agent37-pi`](https://www.agent37.com/docs/agents-api/pi) is a system
template with the managed model already wired.

> [!WARNING]
>
> **Reference the variable, never copy its value.** The token is reissued, and the previous one
> revoked immediately, on create, start, restart, update, resize, migrate, and recovery. A config
> written once with the literal token baked in keeps working until the first restart and then
> fails with `401` forever, because your config file is on the persistent volume and survives the
> rotation. If your agent cannot read env vars from its config, have the entrypoint rewrite that
> file from `$AGENT37_MANAGED_TOKEN` on **every** boot, unconditionally. Write-if-absent is the
> bug.

## Budgets

Paid calls across all four services debit the workspace wallet within the instance
[budget](https://www.agent37.com/docs/agents-api/budgets.md). LLM calls pass through OpenRouter inference cost with no markup;
Brave calls cost \$0.005 each; billable Composio tool calls cost \$0.000114 each; Perflo passes
through its reported charge with no markup. Check spend with `GET /v1/instances/{id}/usage`.
Budget or wallet refusals are a `402`:

```json theme={null}
{ "error": { "type": "instance_budget_exhausted", "message": "..." } }
```

`insufficient_balance` is the other `type`, meaning the workspace wallet is empty rather than
the instance cap being reached.

> [!WARNING]
>
> **An instance created without a budget has a cap of zero, and paid managed calls return `402`.**
> Pass one at create, or `PATCH /v1/instances/{id}/budget` with `monthly_cap_micros`. Agents often
> surface this badly: a `402` from the model endpoint can look like a hang rather than an error.
> If a new instance's agent does nothing, read `GET /v1/instances/{id}/budget` first.

## Filesystem rules for a custom image

`/home/node` is a persistent volume bind-mounted over your image at
runtime. The volume is created **empty**, and nothing is ever copied out of the image into it, so
anything your image writes under that path is unreachable from the running container.

This catches people twice, because npm's default global prefix is under `/home/node`:

```dockerfile theme={null}
RUN npm install -g my-agent                        # vanishes at boot
RUN NPM_CONFIG_PREFIX=/usr/local npm install -g my-agent   # survives
```

Put binaries in `/usr/local`, and put config your agent reads at startup somewhere outside
`/home` too, or have the entrypoint write it into the volume on every boot. Files your agent
creates at runtime under `/home/node` persist normally across restarts and image updates.

## Not using them

Nothing obliges your image to touch these endpoints. To run on your own model, ignore the proxy
variables and point your agent at your own provider, as in
[Build a custom image](https://www.agent37.com/docs/agents-api/custom-image.md#bring-your-own-model-instead). To skip integrations
or paid tools, leave that MCP server out of your agent's config. Unused endpoints are never billed,
because billing is per call.

On a **stock template**, where we write the agent's config at every boot, the switch is an
environment variable you set at create:

| Variable | Turns off |
| - | - |
| `AGENT37_MANAGED_PLUGIN_BRAVE_ENABLED` | Managed web search (Brave) |
| `AGENT37_MANAGED_PLUGIN_COMPOSIO_ENABLED` | Managed [app integrations](https://www.agent37.com/docs/agents-api/integrations.md) (Composio) |
| `AGENT37_MANAGED_PLUGIN_PERFLO_ENABLED` | [Paid tools](#paid-tools) (Perflo) |

```bash theme={null}
curl -X POST https://api.agent37.com/v1/instances \
  -H "Authorization: Bearer $AGENT37_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "agent37-hermes",
    "env": { "AGENT37_MANAGED_PLUGIN_PERFLO_ENABLED": "false" }
  }'
```

Set to `false`, the template leaves that server or plugin out, so the agent never sees those tools.
The other services keep working, and turning one back on is an
[env edit](https://www.agent37.com/docs/agents-api/instances/edit.md) plus a restart. Leaving all three on costs nothing until the
agent calls one.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.