Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

LLM Function Calling Patterns Cheat Sheet

LLM Function Calling Patterns Cheat Sheet

Back to Generative AI
Updated 2026-05-21
Next Topic: LLM Guardrails and Safety Patterns Cheat Sheet

Function calling (also called tool use) is the mechanism by which large language models bridge natural language understanding and structured programmatic execution — the model does not run code itself, but emits a structured description of what should be called and with which arguments, letting your application execute and return the result. It is the core primitive underpinning modern AI agents, enabling models to query databases, call REST APIs, search the web, and write files. The critical mental model: function calling is a contract between your schema and the model — the quality of your descriptions and parameter definitions directly determines reliability, and every round-trip through the tool loop is an extra API call that adds latency and cost.

What This Cheat Sheet Covers

This topic spans 12 focused tables and 92 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: JSON Schema Tool Definition StructureTable 2: Tool Choice / Tool Config ControlTable 3: Provider Response FormatsTable 4: Single-Turn vs. Multi-Turn Tool PatternsTable 5: Parallel Tool CallsTable 6: Structured Outputs and Strict ModeTable 7: Pydantic and Instructor PatternsTable 8: Tool Error Handling and Retry PatternsTable 9: Comparison — Function Calling vs. JSON Mode vs. MCPTable 10: OpenAI vs. Anthropic vs. Google — Format Differences at a GlanceTable 11: Benchmarks — BFCL and Tau-BenchTable 12: Tool Design Best Practices

Table 1: JSON Schema Tool Definition Structure

Every provider requires you to describe your tools using a JSON Schema subset. Getting this structure right is the single most important step in function calling: the model uses your names, descriptions, and parameter definitions to decide when and how to call each tool.

PatternExampleDescription
OpenAI tools array
{"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}},
"required": ["location"]
}
}}
Tools are passed in a tools array; each entry has type: "function" wrapping a function object with name, description, and parameters (a JSON Schema object).
Anthropic input_schema
{"name": "get_weather",
"description": "Get current weather",
"input_schema": {
"type": "object",
"properties": {
"location": {"type": "string"}},
"required": ["location"]
}}
Anthropic uses input_schema (not parameters) for the JSON Schema object; tools are passed in a top-level tools array on the messages request.
Gemini function_declarations
{"function_declarations": [{
"name": "get_weather",
"description": "Get weather",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}},
"required": ["location"]
}
}]}
Gemini wraps declarations in a function_declarations list inside a tools array; schema format follows OpenAPI 3.0 conventions.
JSON Schema type
"type": "string" / "integer" / "number" / "boolean" / "array" / "object"
Standard JSON Schema primitive types; map directly from Python (str→string, int→integer, float→number, bool→boolean, list→array, dict→object).
required array
"required": ["location", "unit"]
Lists parameters the model must provide; omitted parameters are treated as optional and may or may not be included.

More in Generative AI

  • LLM Fine-tuning Cheat Sheet
  • LLM Guardrails and Safety Patterns Cheat Sheet
  • Advanced RAG Patterns and Optimization Cheat Sheet
  • ColBERT and Late Interaction Retrieval Cheat Sheet
  • LangSmith Cheat Sheet
  • pgvector for Postgres Vector Search Cheat Sheet
View all 95 topics in Generative AI