ChatGPT Prompt for Reliable Function and Tool Calling
This is a function and tool calling prompt for developers wiring ChatGPT, Claude, or Gemini into an app that has real tools available β a search API, a database lookup, a calculator, a calendar. It solves the most common failure mode in tool-using assistants: the model either calls a tool when it didn't need to, skips a tool call when it should have used one, or fabricates a plausible-looking function argument instead of asking for a missing value.
The template works by giving the model an explicit decision rule before it sees the tool list: check whether the question can be answered from context alone, check whether a required argument is actually present in the conversation, and only then call a tool. It also forces the model to state why it's calling a tool, which makes bad calls easy to catch in logs and easy to debug when a pipeline misbehaves.
This is not model-specific β the same decision structure works whether you're wiring up OpenAI's function calling, Anthropic's tool use, or Gemini's function declarations, since the reasoning happens in the prompt, not the API schema.
Prompt template
Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.
Example input
When to use it
- You're building an agent or chatbot that has one or more tools/functions available and it's calling them inconsistently
- The model is calling a tool even when the answer was already in the conversation or system prompt
- The model is guessing at required arguments instead of asking the user for missing information
- You need a debuggable trail of why each tool call happened, not just which tool was called
Best practices
- List each tool with a one-line description of exactly when to use it, not just what it does
- Require the model to name which required arguments it has and which are missing before calling anything
- Tell the model explicitly that it's allowed to answer directly with no tool call when no tool is needed
- Test the prompt against edge cases where a tool looks relevant but isn't actually required
Common mistakes
- Listing tools without saying when NOT to use them, so the model defaults to calling one every turn
- Letting the model invent a plausible value for a missing required argument instead of asking for it
- Not asking the model to explain its reasoning, making bad tool calls invisible until they break something downstream
- Assuming the same prompt structure automatically transfers across providers without checking each one's tool-calling format
FAQs
Does this prompt work the same way for OpenAI, Claude, and Gemini function calling?
The reasoning structure (decide, pick one tool, check arguments, ask if missing) is model-agnostic and works for all three. What differs is the technical schema each provider expects for the tool definitions themselves β this prompt handles the reasoning, not the API-level schema.
Why does the prompt make the model explain its reasoning before calling a tool?
Without an explicit reasoning step, bad tool calls are hard to catch until something breaks downstream. Forcing the model to state which tool it picked and why makes incorrect or unnecessary calls visible in logs before they cause a problem.
How do I stop the model from calling a tool on every single turn?
Most over-calling happens because the tool descriptions only say what a tool does, not when to use it. Add an explicit "use only when..." condition to every tool description, and tell the model directly that answering with no tool call is a valid outcome.
What should the model do if a required argument is missing?
It should ask the user for the missing value rather than guessing. The prompt template makes this an explicit step so the model isn't left to decide on its own whether guessing is acceptable.
Can this prompt handle a case where more than one tool could apply?
Yes β step 2 asks the model to pick the single best-fit tool rather than calling multiple tools speculatively. If your use case genuinely needs multiple sequential tool calls, extend step 5 to loop back to step 1 after each call.