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
Models Supporting Function Calling
Models Supporting Function Calling
- OpenAI
- gpt-4
- gpt-4-1106-preview
- gpt-4-0613
- gpt-3.5-turbo
- gpt-3.5-turbo-1106
- gpt-3.5-turbo-0613
- Anyscale
- mistral-7b-instruct
- OpenAI
- gpt-4-1106-preview
- gpt-3.5-turbo-1106
- Anyscale
- mistral-7b-instruct
Adding functions to your prompt
For supported models, you can click theAdd 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 tojson_object
.
Note, setting response format to json_object
will require you to use the word JSON
in your prompt.

List of models supporting JSON mode
List of models supporting JSON mode
- OpenAI
gpt-3.5-turbo
gpt-3.5-turbo-1106
gpt-3.5-turbo-0125
gpt-4-turbo-preview
gpt-4-1106-preview
gpt-4-0125-preview
- Mistral
mistral-small-latest
mistral-large-latest