In the playground, you can describe functions and have the LLM model intelligently choose to output a JSON object containing arguments to call one or many functions.

Common use cases

Function calling allows you to get structured data back from the model more reliably. For example, you can:

  • Create assistants that answer questions by calling external APIs (e.g., like ChatGPT Plugins)
    • e.g. define functions like send_email(to: string, body: string), or get_current_weather(location: string, unit: ‘Celsius’ | ‘Fahrenheit’)
  • Convert natural language into API calls
    • e.g., convert “Who are my top customers?” to get_customers(min_revenue: int, created_before: string, limit: int) and call your internal API
  • Extract structured data from text
    • e.g. define a function called extract_data(name: string, birthday: string), or sql_query(query: string)
  • Classification tasks
    • e.g., define a function schema that has an enum for the class [“Type1”, “Type2”] and instruct the model to select only one based on some input

…and much more!

Adding functions to your prompt

For supported models, you can click the Add function(s) button, which will open a modal to add existing functions to your prompt or allow you to create a new one.

Functions are version-controlled. You can select the version of the functions you want and then click the switch to enable the functions.

You can also create a new function by defining your function JSON schema in the editor. The parameters the function accepts should be described as a JSON Schema object. See the OpenAI guide for examples, and the JSON Schema reference for documentation about the format. To describe a function that accepts no parameters, provide the value { "type": "object", "properties": {} }.

Copying an existing from your IDE, click the Fix schema button to fix the formatting automatically. Fix schema ensures you are following OpenAI json schema requirements. Changes made include:

  • Ensuring name matches regex: ^[a-zA-Z0-9_-]{1,64}$
  • Replacing spaces and special characters in property names with hyphens
  • Ensuring the required list has updated property names and has the correct placement


Setting Response format to JSON

Alternatively, you can force some OpenAI & Mistral models to response with JSON by setting the response format to json_object. Note, setting response format to json_object will require you to use the word JSON in your prompt.