OpenAI

Function calling in the Chat Playground

You can use function calling in the OpenAI Playground.

Updated: 29 minutes ago

Function calling allows you to describe any custom functions or external APIs to the assistant, which enables the assistant to intelligently call those functions by outputting a JSON object containing the relevant arguments.

Use function calling in the Chat Playground

In the Playground, open the tool settings and add a function.

Then, enter the JSON schema with the function's parameters. You can use beta Generate functionality to describe what you would like the function to do in plain text, to get a suggested JSON schema.

You’ll now see the function listed under Tools.

To test the function in the playground, enter a message that would trigger the model to call the function.

For example, for the get_weather function, enter: "what is the weather in Berkeley?"

When the function is called, enter the output of your function, for example, {"temp": 80}, and select Run. The assistant will then use the output of the function you’ve supplied for its response.

Does this support parallel function calling?

Yes, parallel function calling is supported in the Chat Playground.

Parallel function calling is the model's ability to perform multiple function calls together, allowing the effects and results of these function calls to be resolved in parallel. This is especially useful if functions take a long time, and reduces round trips with the API.

Turn on Structured Outputs by setting strict: true in the function definition

When Structured Outputs is turned on, the arguments generated by the model for function calls are guaranteed to match the JSON Schema that you provide.

If you are not using Structured Outputs, then the structure of arguments is not guaranteed to be correct, so we recommend the use of a validation library like Pydantic to first verify the arguments prior to using them.


Learn more about function calling with structured outputs.

Force function choice in the Playground

  1. Select the Settings icon next to the model name.

  2. Select Tool Choice.

  3. Change from Auto to Required or to the desired function (previously created).

Was this article helpful?