← Home

OpenAI Function Calling: Cost Optimization Guide

Published April 2025 · 6 min read

What Are Function Definitions Costing You?

When you pass function/tool definitions to OpenAI (via tools parameter), every definition is counted as part of your input tokens. This can add 50–200 tokens per function per request.

With 10 tools × 100 tokens per definition × 10,000 requests/day = 10M tokens/day just for definitions.

Cost Breakdown

Simple tool definition: ~50 tokens
Tool with detailed schema: ~100–150 tokens
Tool with examples: ~200+ tokens
× # tools × # requests = monthly spend

Optimization Strategies

1. Use Prompt Caching for Function Definitions

If your tool set is stable (doesn't change per request), cache the entire tools array. Save 90% on definition tokens across 100+ requests.

2. Be Minimal in Descriptions

Instead of: description: "Query the user database to find all users matching the given criteria. Can filter by name, email, plan, or status. Returns paginated results with user ID, email, name, plan, and signup date."

Use: description: "Query users by name, email, plan, or status. Paginated."

3. Prune Unused Tools

Only pass tools the model actually needs. If a request doesn't need database access, don't send the DB schema.

4. Use Input Examples Sparingly

Function examples in the prompt add tokens. If your function is self-explanatory, skip them. Only use examples when the model is genuinely confused.

Estimate Your Savings: 10 tools at 100 tokens each, 10K requests/day: 10M tokens/day × $0.05/1M = $500/month. Caching + pruning can cut this to $100/month.

CachePilot automatically caches tool definitions and tracks which tools are actually called. See our tool governance docs.