# Set yourself up and buy

For an AI agent: connect yourself to Paygynt, check your budget, then find, buy and use APIs, data and compute within your company's rules.

You are an AI agent. Your company uses Paygynt so you can buy APIs, data, MCP servers and compute when your work needs them, within a monthly budget and rules your company set. Follow these steps in order.

## 1. Connect to Paygynt

Paygynt's MCP server is `https://mcp.paygynt.com/mcp`. If you already have Paygynt's tools, such as `get_budget` and `search_offerings`, go to step 2.

Your person gave you a Paygynt key with these instructions. It is a secret. Keep it in an environment variable, such as `PAYGYNT_KEY`, or in your app's secret store. Never put it in code, in files you commit, or in your replies.

Add the server to the app you run in, with the key as a Bearer token. Replace `YOUR_AGENT_KEY` with your key.

### Claude Code

```
claude mcp add --transport http paygynt https://mcp.paygynt.com/mcp --header "Authorization: Bearer YOUR_AGENT_KEY"
```

### Cursor

```
// ~/.cursor/mcp.json, or .cursor/mcp.json in a project
{
  "mcpServers": {
    "paygynt": {
      "url": "https://mcp.paygynt.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_AGENT_KEY"
      }
    }
  }
}
```

### VS Code

```
// .vscode/mcp.json in your workspace
{
  "servers": {
    "paygynt": {
      "type": "http",
      "url": "https://mcp.paygynt.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_AGENT_KEY"
      }
    }
  }
}
```

### n8n

```
In an AI Agent's MCP Client Tool node:
Endpoint: https://mcp.paygynt.com/mcp
Server Transport: HTTP Streamable
Authentication: Header Auth, with a new credential:
  Name: Authorization
  Value: Bearer YOUR_AGENT_KEY
```

### OpenAI API

```
from openai import OpenAI

client = OpenAI()
response = client.responses.create(
    model="gpt-5",
    tools=[{
        "type": "mcp",
        "server_label": "paygynt",
        "server_url": "https://mcp.paygynt.com/mcp",
        "headers": {"Authorization": "Bearer YOUR_AGENT_KEY"},
        "require_approval": "never",  # the agent's budget and approvals on Paygynt still apply
    }],
    input="Find a weather API and get tomorrow's forecast for Austin, TX.",
)
print(response.output_text)
```

### Claude API

```
import anthropic

client = anthropic.Anthropic()
response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    betas=["mcp-client-2025-11-20", "server-side-fallback-2026-07-01"],
    fallbacks="default",  # if the model declines, another model carries on
    mcp_servers=[{"type": "url", "url": "https://mcp.paygynt.com/mcp", "name": "paygynt", "authorization_token": "YOUR_AGENT_KEY"}],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "paygynt"}],
    messages=[{"role": "user", "content": "Find a weather API and get tomorrow's forecast for Austin, TX."}],
)
print("".join(b.text for b in response.content if b.type == "text"))
```

### Any other app

```
{
  "mcpServers": {
    "paygynt": {
      "type": "http",
      "url": "https://mcp.paygynt.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_AGENT_KEY"
      }
    }
  }
}
```

Your app may need a restart before the tools appear. If you run in claude.ai or ChatGPT, you cannot add the server yourself: ask your person to add `https://mcp.paygynt.com/mcp` as a connector, sign in, and approve you.

## 2. Check, and tell your person

Call `get_budget`. Tell your person that you are connected, what your monthly budget is and what is left, and that you will buy only what your work needs.

## 3. Buy what you need

1. **Find it.** Call `search_offerings` with a few words, such as `q: "weather forecast"`. You only see what your rules allow.
2. **Reuse what you have.** An offering marked `task_in_progress` means you already have a task with it. Call `get_task` and use that.
3. **Price it.** Call `get_quote` with the plan's `variant_id` and a `quantity`, such as 10 calls. The quote is valid for 5 minutes.
4. **Buy it.** Call `place_hold` with the `quote_id` and a new unique `idempotency_key`. You get a `task_id` and a `token`.
5. **Use it,** as step 4 says. You are billed only for what you use, up to what you bought.
6. **Extend or finish.** To go past the limit, call `get_quote` with `extends` set to the task's latest `hold_id`, then `place_hold`. If you finish early, call `release_hold`, and what is unused goes back to your budget.

## 4. Call what you bought

Send the token on every call to the service:

```
Authorization: Bearer <token>
```

The offering's description says where to call it and how. For example, Weathry's forecasts:

```
GET https://api.paygynt.com/weathry/forecast/daily?lat=40.71&lon=-74.01&unit=I
```

What the service answers:

- `200`: Served. Billed.
- `400`: The request was wrong. Fix it. Not billed.
- `401`: The token is missing or expired. get_task gives a fresh one. Not billed.
- `402 limit_reached`: The task used everything it bought. Extend it, or buy again. Not billed.
- `402 task_ended`: The task has ended. Buy again. Not billed.
- `502`: The service behind it failed. Try again later. Not billed.
- `503`: Paygynt could not confirm the task. Try again. Not billed.

## 5. When a purchase needs approval

A purchase over your approval amount fails with `needs_approval` and an `approval_id`. Tell your person what you want to buy and why. Then call `get_approval` from time to time. Once it is approved, it gives you the task and the token. A request nobody answers expires after an hour, and nothing is charged.

## When something is refused

- `over_budget`: It costs more than is left (remaining). Buy less, or ask your person to raise the limit.
- `not_allowed`: The agent's rules do not allow it. Ask your person.
- `needs_approval`: It is over the approval amount. Tell your person, then check get_approval.
- `approval_declined`: Your person said no. Do not buy it.
- `approval_expired`: Nobody answered within an hour. Ask again only if it is still needed.
- `quote_expired`: The quote is older than 5 minutes. Get a new quote.
- `task_in_progress`: There is already a task with that offering. Use it: get_task.
- `seller_unavailable`: It cannot be sold now. Find another.
- `search_unavailable`: Search is down for a moment. Try again shortly.
- `unavailable`: Paygynt could not be reached. Retry with the same idempotency_key.

## Good habits

- **Buy small.** Buy what the work needs now, and extend if you need more.
- **Retry safely.** After `unavailable`, call again with the same `idempotency_key`. You will not buy twice.
- **See the limit coming.** Ask for `notify_at_percent` when you buy, and you get an `extension_due` event before the limit.
- **Say what you spend.** When you finish, tell your person what you bought, from whom, and what it cost.

Every tool, with its inputs: [the tool reference](https://paygynt.com/docs/tools.md).
