Today, new artificial intelligence models are released every six months, such as GPT 5.6, Fable 5, Kimi K3 and many others.

And now the most active discussion in the technical community is the concept of tokens, which allows us to use LLM in our favorite IDEs such as Cursor.

Plans are quite expensive today and every request is important to the business. In this article, I would like to tell you how you can save your money using LLM using one tool.

Well, let's get started!

🖥️ Real example

Instead of words, let's look at one small example that I prepared for you:

Request 1 (2,350 tokens): "Fetch the data from the endpoint..."
↓ (Model reasons about what to do)
Request 2 (3,100 tokens): "Here's the response. Now transform it..."
↓ (Model reasons again)
Request 3 (2,900 tokens): "Now check these projects..."
↓ (Model reasons about results)
Request 4 (2,500 tokens): "Generate a summary based on..."
↓
Total: 10,850 tokens = $0.32 per execution

Enter fullscreen mode Exit fullscreen mode

Now let's imagine that our entire business is built on these requests. The site can have as many users as you like, and each such request to LLM spends our money. Considering that the plans of providers like Claude, although not so expensive, are still a serious budget expenditure. You will have to think through a business model so that it makes a profit.

👀 What do I want to suggest in this situation?

If you have a small business and want to cut down on the costs of using tokens, I suggest you try Bifrost, which recently made a super useful feature called Code Mode.

Code Mode

Code Mode is a transformative approach to using MCP that solves a critical problem at scale:

The Problem: When you connect 8-10 MCP servers (150+ tools), every single request includes all tool definitions in the context. The LLM spends most of its budget reading tool catalogs instead of doing actual work.

Instead of exposing 150 tools directly, Code Mode exposes just four generic tools. The LLM uses those tools to write Starlark that orchestrates everything else in a sandbox.

📊 Comparison

Since I have written many articles on the topic of Bifrost, you already know how to work with it. Let's try to apply what I wanted. First of all, here's what I want to do:

Default Mode:
Request 1: "Use the database tool to fetch data"
  → Model reasons, calls tool
  → Response: 2,450 tokens

Request 2: "Transform the result..."
  → Model reasons, calls tool
  → Response: 3,100 tokens

Total Requests: 4+ API calls
Total Tokens: 10,850+

Enter fullscreen mode Exit fullscreen mode

Now working with the solution:

Code Mode:
Request 1: "Here's what I need. Write Python to do it."
  → Model writes code (single request)
  → Python executes all tools in sequence
  → Results fed back in one batch

Total Requests: 1 API call
Total Tokens: 850

Enter fullscreen mode Exit fullscreen mode

If you think this is some kind of deception, then no. The reason here is very simple. Language models are good at writing code. Bad at reasoning step-by-step through tool chains.

Round MCP Footprint Pass Rate (Classic) Pass Rate (Code Mode) Input Tokens (Classic) Input Tokens (Code Mode) Token Reduction Cost (Classic) Cost (Code Mode) Cost Savings
1 96 tools / 6 servers 64/64 (100%) 64/64 (100%) 19.9M 8.3M -58.2% $104.04 $46.06 -55.7%
2 251 tools / 11 servers 64/65 (98.5%) 65/65 (100%) 35.7M 5.5M -84.5% $180.07 $29.80 -83.4%
3 508 tools / 16 servers 65/65 (100%) 65/65 (100%) 75.1M TBD TBD TBD TBD TBD

diagram

At around 500 tools, Code Mode reduced average input tokens per query by roughly 14x: from 1.15M tokens to 83K tokens. See the Bifrost MCP Gateway benchmark writeup, or explore the complete benchmark report.

⚙️ Application

Let's set up a virtual key for our employee in the company. To do this, let's describe the following json:

{
  "virtual_key": "vk-data",

  "token_budget": {
    "daily_limit": 1000000,
    "monthly_limit": 20000000,
    "cost_limit": "$500/day"
  },

  "token_alerts": {
    "threshold_percent": [75, 90, 100],
    "notify": ["[email protected]"]
  },

  "allowed_mcp_tools": [
    "database",
    "api-client",
    "csv-processor"
  ],
  "blocked_mcp_tools": [
    "file-system",
    "external-web-scraper"
  ]
}

Enter fullscreen mode Exit fullscreen mode

And enable Code Mode for the product:

{
  "virtual_key": "vk-product",
  "code_mode": {
    "enabled": true,
    "max_code_memory": 512,  // MB
    "allowed_imports": ["requests"],
    "blocked_imports": ["subprocess", "os"]
  },
  "mcp_token_budget": 1000000
}

Enter fullscreen mode Exit fullscreen mode

Let's say our company works with Code Mode enabled, here are the results the business will have when working:

Organization Token Budget: 100,000,000 tokens/month

├─ Engineering: 40,000,000 tokens
│  ├─ Backend services: 30,000,000 (Code Mode enabled)
│  ├─ Data processing: 10,000,000 (Code Mode enabled)
│
├─ Product: 20,000,000 tokens
│  ├─ Analytics: 15,000,000 (Code Mode enabled)
│  ├─ User research: 5,000,000 (No Code Mode needed)
│
├─ Research: 40,000,000 tokens
│  ├─ Experiments: 30,000,000 (Mixed mode)
│  └─ Exploration: 10,000,000 (Text)

Enter fullscreen mode Exit fullscreen mode

As a result, we fit within the company's budget. If we were to create a budget based on a simple request for LLM, then we would use more tokens for requests, and accordingly, money would also be spent on tokens.

💻 Using Code Mode with multiple MCP tools at once

Also, along with code mode, you can configure MCP Tool Groups, which will allow us to conveniently configure the context without adding several dozen tools there manually.

{
  "mcp_tool_groups": [
    {
      "name": "api-integration",
      "tools": [
        "http-get",
        "http-post",
        "http-auth",
        "rate-limiter"
      ],
      "required_for": ["backend", "integrations"]
    },
    {
      "name": "data-transformation",
      "tools": [
        "csv-parse",
        "json-transform",
        "data-validate",
        "format-output"
      ],
      "required_for": ["data-processing", "analytics"]
    }
  ]
}

Enter fullscreen mode Exit fullscreen mode

Then assign Tool Groups to Virtual Keys:

{
  "virtual_key": "vk-backend",
  "allowed_tool_groups": [
    "database-operations",
    "api-integration"
  ],
  "code_mode": {
    "enabled": true,
    "max_code_memory": 512,
  }
}

Enter fullscreen mode Exit fullscreen mode

This will also save time on use, improve security, and, most importantly, LLM will only see groups of tools, not the entire list, which will save time on data processing.

Without Tool Groups (50 tools visible):
├─ Initial prompt: 8,000 tokens (reading all tool definitions)
├─ Code generation: 4,000 tokens
└─ Total: 10,000 tokens

With Tool Groups (5 tools visible):
├─ Initial prompt: 1,500 tokens (reading relevant tools only)
├─ Code generation: 600 tokens
└─ Total: 4,000 tokens

Enter fullscreen mode Exit fullscreen mode

✅ Conclusion

In my opinion, the code mode is not just a function, but a super method in the approach of enterprises to the agency economy. At scale, Code Mode achieves a 58% to 85% reduction in token count depending on complexity, which directly translates to 56% to 83% cost savings. You can spend this money on marketing.

🔗 Resources:

Thanks for reading this article! ❤️

I'd love to hear your thoughts on this mode in the comments!