Skip to main content
Function calling (or Tool calling) lets LLMs interact with external APIs by generating structured arguments for specific functions. This enables LLMs to fetch real-time data, perform calculations, or trigger actions. Portkey supports function calling across 3000+ models including those from all major providers.

How it Works

  1. Define tools: Tell the model about available functions and their parameters.
  2. Generate arguments: The model decides to call a tool and returns the arguments.
  3. Execute tool: Run the function in your application.
  4. Final answer: Send the tool output back to the model to generate a natural language response.

Example: Weather Forecast

To get the weather for a specific location:
The model returns a JSON object with the function name and arguments:
Pass the tool output back to the model to complete the loop:

Unified API Support

Portkey supports function calling across different API formats. Use the one that fits your application to call any provider’s model.

/chat/completions

Standard OpenAI-compatible format used by most providers.

/messages

Anthropic-compatible format supported by all models through Portkey’s translation.

/responses

Unified agentic format for multi-provider interoperability.

Supported Models

Portkey provides native function calling support for all major providers. If you discover a function-calling capable LLM that isn’t working with Portkey, please let us know on Discord.
Portkey supports parallel tool calling for models that provide it. This allows the model to trigger multiple functions in a single request. See the parallel function calling guide.
Last modified on April 8, 2026