• MONITOR
  • PROTECT
  • AUDIT
  • MANUAL

How to enforce LLM budget policies with your AI

Connect Portkey to your agent to track real-time token consumption and stop runaway costs before they happen.

Ask AI about this page

Short answer

How can I stop my AI from overspending on tokens?

Your agent uses Portkey to pull usage logs and apply specific spending constraints. You can set hard limits that trigger once a certain threshold is hit. This setup ensures your agent stays within budget automatically.

Where every limit lands.

Budget control outcomes

The AI manages your Portkey configuration to keep costs predictable.

MONITOR

Real-time usage tracking

The agent pulls recent logs to show exactly how many tokens you've used. You get a clear view of current spend.

PROTECT

Hard spending caps

Your agent creates new policies that kill requests once they hit a limit. This prevents massive bills from loops.

AUDIT

Policy management

The agent lists your existing rules to ensure no overlapping or conflicting limits exist. You maintain full visibility.

MANUAL

Human oversight

You decide when to delete old rules or adjust thresholds. The AI suggests changes, but you hold the final say.

The workflow

What your AI does when the budget is exceeded.

The agent acts as a financial watchdog for your LLM calls.

  1. Analyze usage

    The agent checks your recent token consumption to see if you are approaching a limit.

    list_logs
  2. Review rules

    It looks at your current Portkey setup to see what constraints are already active.

    list_policies
  3. Apply limits

    The agent creates a new policy to block further requests if a specific budget is hit.

    create_policy
  4. Clean up

    If a policy is no longer needed, the agent removes it to keep your configuration clean.

    delete_policy

Try it

Copy these to start.

Use these prompts to begin managing your Portkey budget.

Starting points

Swap out the specific policy names or token counts for your own requirements.

Portkey Connector

You're all set. Choose your MCP client and follow the setup instructions.

Connector linkhttps://edge.vinkius.com/vk_preview_BpHtQMK896fkGyepmah9cM552NpibU6fUP5BakNG/mcp

Claude Desktop

Follow the steps below to connect in seconds.

  1. 1In Claude Desktop, open Settings → Connectors.
  2. 2Click “Add custom connector” and paste the connector link above as the remote MCP server URL.
  3. 3Click Add and start a new chat — Portkey capabilities are ready to use.
Configuration · claude_desktop_config.jsonCopy
{
  "mcpServers": {
    "portkey-mcp": {
      "url": "https://edge.vinkius.com/vk_preview_BpHtQMK896fkGyepmah9cM552NpibU6fUP5BakNG/mcp"
    }
  }
}
Copy into chat04
  • Check my recent Portkey logs to see how many tokens I've used today.

  • List all my current Portkey policies so I can see my active limits.

  • Create a new Portkey policy to limit my token spend for this project.

  • Delete the old budget policy named 'test-limit-123'.

  • Claude
  • ChatGPT
  • Cursor
  • VS Code
  • Windsurf
  • Claude Code
  • JetBrains
  • Cline

Start here

Connect Portkey once, then ask.

Just link your Portkey account. Your credentials stay encrypted, and you can immediately start managing limits through your agent.

Connect Portkey to your AI

FAQ

How this task behaves

  • 01

    Can the AI change my actual Portkey billing settings?

    No. The AI only manages policies and logs through the provided tools; it cannot access your credit card or billing account.

  • 02

    Will the AI delete my policies without asking?

    No. The agent only deletes policies when you explicitly tell it to do so in a prompt.

  • 03

    Can I see exactly which model is costing me the most?

    Yes, the agent can pull logs to help you identify which models are driving your token spend.

  • 04

    Does the AI automatically stop a request if it's too expensive?

    Yes, if you have a policy in place that the agent has created or verified, Portkey will enforce that limit.

  • 05

    Can the AI create a policy for a specific API key?

    Yes, the agent can create policies to manage how different keys or projects are constrained.

  • More questions about Portkey? See everything the Portkey Connector can do

Connect Portkey to Claude, Cursor, ChatGPT & more