August 22nd, 2025
0 reactions

Unlocking GPT-5’s Freeform Tool Calling: A New Era of Seamless Integration

Ananya Bishnoi
Technical Program Manager

GPT-5 models are now available in Azure AI Foundry via Azure OpenAI. Designed for advanced reasoning and generation. One of the core capabilities of the model is tool calling, which enables it to interact with external systems by generating and sending raw text directly to tools. 

What Is Freeform Tool Calling in GPT-5? 

Freeform tool calling is a powerful capability in GPT-5 that allows the model to send raw text payloads like Python scripts, SQL queries, or configuration files directly to external tools without needing to wrap them in structured JSON. This means the model can generate code or text in the exact format your tool expects, making integration smoother and more flexible. 

While traditional tool calling supports complex tasks such as code execution, configuration generation, and scripting, it typically requires strict formatting. Freeform tool calling, by contrast, allows GPT-5 to interact with tools using natural text output, which: 

  • Simplifies development workflows 
  • Enables richer and more intuitive interactions 
  • Maintains support for complex tasks in a more flexible and expressive way 

video not found

To better understand how freeform tool calling works in practice, Lets walk through the demo demonstrated in the gif by Liam Cavanagh that chains two tools together- one for SQL and one for Python. 

Step 1: Setup 

We begin by loading environment variables from a .env file and initializing the Azure OpenAI client. The client supports both API key and Entra ID authentication: 

Image not found

Step 2: Define Custom Tools 

We define two tools: 

  • sql_exec_sqlite: Executes SQL and returns CSV from the final SELECT. 
  • code_exec_python: Executes raw Python and returns stdout. 

image not found

Step 3: Prompt GPT-5 

We give GPT-5 a prompt to: 

  • Generate SQL to create a sales table and compute revenue. 
  • Call sql_exec_sqlite to execute it. 
  • Call code_exec_python to format the result. 

Image not found

Step 4: Run the Conversation 

We use a loop to detect tool calls, execute them, and feed the result back to GPT-5. 

The run conversation() function drives the interaction: 

  • It sends the prompt to GPT-5. 
  • Detects if the model wants to call a tool. 
  • Executes the tool locally. 
  • Sends the result back to the model as a function_call_output. 
  • Prints the final assistant response. 

This loop ensures that the model can chain tool calls and maintain context across steps. 

image not found

Result 

The final output is a clean, formatted summary of product revenues, generated and executed entirely through GPT-5’s freeform tool calling. 

image not found

Key Takeaways 

  • No JSON required: GPT-5 sends raw code directly to tools. 
  • Natural output: Improves usability and readability. 
  • Multi-tool orchestration: Handles complex workflows with precision. 
  • Ideal for developers: Enables dynamic scripting, benchmarking, and automation.

Next Steps

Author

Ananya Bishnoi
Technical Program Manager

0 comments