---
title: How to Make a treg.to API Call and Cap What It Costs
url: "https://goremy.ai/blog/articles/treg-to-llms-txt-http-api-call-max-cost"
author: Luis Chavez-Mattos
editor: Luis Chavez-Mattos
editor_title: Director, Product
published: "2026-12-04T19:40:15.829Z"
updated: "2026-12-04T19:40:15.829Z"
topic: AI Agents & Automation
description: "How to call a treg.to endpoint over HTTP: what llms.txt does, which header carries your token, and how to limit spend on a call. One request, step by step."
---

# How to Make a treg.to API Call and Cap What It Costs

> How to call a treg.to endpoint over HTTP: what llms.txt does, which header carries your token, and how to limit spend on a call. One request, step by step.

Edited by Luis Chavez-Mattos, Director, Product · Published 2026-12-04

## How do you make an HTTP call to a treg.to endpoint?

You send a request to `https://treg.to/call/` followed by the endpoint's ID, with your treg token in an `X-Treg-Token` header. You use the provider's own parameters in the body, and treg adds the provider's credential on its side and returns the provider's answer unchanged. Spend is metered against your prepaid balance unless you bring your own provider key. One note on the cost cap: the header documented in the sources is `X-Treg-Route-Max-Cost`, not `x-treg-max-cost-usd`. More on that below.

## TL;DR

- **One base URL and one token** cover every call: `https://treg.to/call/<endpoint-id>` with an `X-Treg-Token` header.
- **llms.txt is the setup file for a coding agent**, not the request itself. It installs the CLI and skill and links `/skill.md`, the guide to calls, prices, errors and retries.
- **Do not send your treg token as `Authorization: Bearer`** on REST calls. REST ignores it and returns `401 not authenticated`, and `/call/` forwards that header to the provider.
- **You make the real upstream request.** The provider's own path and parameters go in your call, and treg relays the response verbatim.
- **The cost cap documented in the sources is `X-Treg-Route-Max-Cost`**, mentioned for capping a whole waterfall of routed calls. I could not find `x-treg-max-cost-usd` in the sources, so check before you rely on it.
- **Price is visible before you spend**, through `treg catalog get <endpoint-id>`, and your prepaid balance puts a ceiling on total spend.

## What is treg.to, and why would you call it directly?

treg.to describes itself as "OpenRouter for agent tools": one key and one place to reach thousands of third-party APIs, such as SEO data, backlinks and lead enrichment. The landing page lists 4,300+ endpoints across 140+ providers. The idea is that an AI agent such as Claude Code can use these tools without you signing up with each vendor.

Most people will let the agent do the calling. But a plain HTTP call is useful when you want to test one endpoint, put a call inside a script, or understand what your agent is doing on your behalf. The API reference describes it as one base URL, one token, and 178 documented operations, plus a proxy to the catalogued provider endpoints through `/call/`.

## Where does llms.txt fit in?

`llms.txt` is a page at `https://treg.to/llms.txt` that you point a coding agent at. According to the API reference, it sets the agent up and links to `/skill.md`, the guide to calls, prices, errors and retries.

The treg Claude Code page shows the usual flow. You send this in the chat:

```
set up treg - https://treg.to/llms.txt
```

The agent reads that page, installs the treg CLI and its skill, and opens a browser for you to sign in. If you would rather do it yourself, the sources give two commands:

```
curl -fsSL https://treg.to/install.sh | sh
treg login
```

So llms.txt tells the agent how to get set up and where to read the rules. It does not hold your key, and it is not where you look up a specific endpoint's parameters. For that you use the catalog, covered below.

## How does the authorization header work?

Authenticated REST requests carry your token in a header named `X-Treg-Token`. That is the whole mechanism for `/call/` and the other REST routes. The catalog routes need no token.

The API reference includes a warning. `Authorization: Bearer` authenticates only the MCP endpoint at `https://treg.to/mcp`. On REST routes, treg ignores it and returns `401 not authenticated`. On `/call/`, treg passes it to the provider like any other header. If you put your treg token there, you may send it to a third party. The reference says plainly to never put your treg token there.

A quick reference:

| Where you are calling | Header to use for your treg token |
|---|---|
| REST routes, including `/call/` | `X-Treg-Token: <token>` |
| MCP endpoint (`https://treg.to/mcp`) | `Authorization: Bearer <token>` |
| Catalog routes | None needed |

Keep the token in an environment variable (the example uses `$TREG_TOKEN`) rather than pasting it into a script you share.

## How do you find the endpoint and its parameters?

Search by what you want to do, not by vendor. The reference gives this route:

```
GET /catalog/search?q=backlinks
```

When several providers can do the same job, `/catalog/platforms/{slug}` lists them side by side with measured success rate, speed and price. The choice is yours. treg compares providers, but it does not route between them automatically and does not fail over.

From the CLI, `treg catalog get <endpoint-id>` shows the price and parameters for one endpoint. The Claude Code page says the agent sees the price before it spends, and you can look at it yourself first.

## What does a complete request look like?

Here is the example from the API reference, a request for URL metrics from Moz:

```
curl -X POST \
  -H "X-Treg-Token: $TREG_TOKEN" \
  -H "content-type: application/json" \
  -d '{"targets":["moz.com"]}' \
  "https://treg.to/call/moz.web.url.metrics"
```

Here is how each piece connects:

1. **The URL.** `https://treg.to` is the base. `/call/` is the proxy prefix. `moz.web.url.metrics` is the catalogued endpoint ID, which you found through search or the catalog.
2. **The method.** POST, because this upstream endpoint expects a body. `/call/{rest}` accepts GET, POST, PUT, PATCH, DELETE and OPTIONS, so you use whatever the provider's endpoint uses.
3. **The token header.** `X-Treg-Token` identifies your account. treg then attaches the provider's credential server-side, so you never hold the provider's secret.
4. **The body.** `{"targets":["moz.com"]}` is the provider's own parameter format. treg does not translate it. That is why an upstream change does not break treg, according to the reference.
5. **The response.** The provider's answer comes back as it is.

Who pays? If your team has its own key for that provider, treg uses it and the call is not metered. Otherwise, eligible endpoints are served on treg's key and metered against your prepaid balance at the provider's own rate. The Claude Code page states $0.000 markup and $1.00 of free credit once per new verified account, with no card.

The CLI does the same thing in a shorter form. This is the pattern the sources show for lead enrichment:

```
treg call treg.people.email.verify --method POST --data '{"email":"jane@acme.com"}'
```

## How do you stop a call from costing more than you set?

The sources describe several layers of control. Only one is a header.

| Control | What it does | Source detail |
|---|---|---|
| Look up the price first | `treg catalog get <endpoint-id>` shows price and parameters before you call | Claude Code page |
| Use your own provider key | The call is not metered by treg | API reference |
| Prepaid balance | Metered calls draw from a balance you fund, so spend has a ceiling | API reference |
| `X-Treg-Route-Max-Cost` header | Caps a whole waterfall of routed calls | Claude Code page |
| Choose the provider yourself | treg does not auto-route or fail over between providers on catalogued endpoints | API reference |

The routed tools, such as `treg.people.search` and `treg.people.email.find`, work differently from a single catalogued endpoint. treg runs the providers for that job, your own keys first, then the cheapest per hit, and the answer names the provider that served it. A chain of those can add up, which is why the Claude Code page says to cap a whole waterfall with the `X-Treg-Route-Max-Cost` header.

The sources do not say what unit that header takes or exactly which routes honor it. So a template with a placeholder is the honest version:

```
curl -X POST \
  -H "X-Treg-Token: $TREG_TOKEN" \
  -H "X-Treg-Route-Max-Cost: <your cap, in the format skill.md specifies>" \
  -H "content-type: application/json" \
  -d '{"email":"jane@acme.com"}' \
  "https://treg.to/call/treg.people.email.verify"
```

Treat that as a pattern to confirm, not a tested request. Read `/skill.md` for the value format before you rely on it.

## Is there an x-treg-max-cost-usd header?

I could not confirm one. Neither the API reference nor the Claude Code page I had mentions `x-treg-max-cost-usd`. The documented header is `X-Treg-Route-Max-Cost`. The header list in the reference also shows `x-treg-org` on several routes, which selects an organization, but that is not a cost control.

If you have seen `x-treg-max-cost-usd` somewhere, check `/skill.md` and the interactive console at `https://treg.to/docs/api`, or the OpenAPI file at `https://treg.to/openapi.json`. If a header is not documented, a server may ignore it without telling you, and then you have no cap at all. A cap you have not tested is not a cap. Run a cheap call with a deliberately tiny limit and see whether it refuses.

## What does this mean for you?

**If you are a marketer, recruiter or sales person using an AI agent:** the agent is making these calls. Ask it to show the price from `treg catalog get` before it runs anything, and tell it to cap chained lookups. The sources show a run of 50 companies ending at 20 verified contacts for $2.33 metered, including news lookups and opener scoring. That works out to $0.12 per deliverable lead, and the 21 companies that failed an eligibility check never reached a paid lookup. Ordering your steps so cheap checks come before paid ones saves real money.

**If you write scripts or automations:** keep the token in an environment variable, use `X-Treg-Token`, and never send `Authorization: Bearer` to `/call/`. Fund only as much balance as you are comfortable losing to a bad loop.

**If you manage a team:** having your team's own provider keys registered means those calls are not metered by treg, so you keep existing vendor terms.

## Can I build a front end for these API calls myself?

If several people want lead lists or SEO pulls without touching curl, a small internal tool can sit in front of calls like these. With [Remy](https://goremy.ai), you describe it in plain English, for example a request form where a teammate enters a company domain, a table that stores each result and what it cost, and a limit that blocks a request once a monthly budget is reached. Remy builds the full-stack app with a database and sign-in and deploys it to a live URL. You own the code. It is a way to give colleagues one controlled place to run lookups instead of sharing a token.

## Frequently Asked Questions

### What header carries my treg.to token?

`X-Treg-Token`. The API reference says REST routes, including `/call/`, authenticate with it. `Authorization: Bearer` works only for the MCP endpoint.

### Why does my call return 401 not authenticated?

A common cause is sending the token as `Authorization: Bearer` on a REST route, which treg ignores. Switch to `X-Treg-Token`. Also check that the token variable is actually set in your shell.

### Does llms.txt contain the endpoint details for my call?

No. It sets up a coding agent and links `/skill.md` for calls, prices, errors and retries. For a specific endpoint, use the catalog search or `treg catalog get <endpoint-id>`.

### Am I charged when I use my own provider key?

According to the API reference, if your team has its own key for that provider, treg uses it and the call is not metered. Otherwise eligible endpoints run on treg's key and draw from your prepaid balance at the provider's own rate.

### Can I rely on a cost cap header for every call?

Only on what the sources document. `X-Treg-Route-Max-Cost` is described for capping a routed waterfall. Confirm in `/skill.md` which calls honor it, and test it with a small limit before trusting it.
