Function Calling in Prompt Studio

Function calling in LLMs using OpenAI model in Orquesta

In this article, we cover:

  1. Function calling
  2. Benefits of OpenAI functions
  3. How to use the OpenAI function in Orquesta
  4. Some important use cases

Function calling

OpenAI's function calling capability enables GPT models to generate structured JSON output, resolving common developer issues caused by irregular outputs. OpenAI is very good at generating responses systematically. You can perform prompt management to optimize your model output and avoid hallucinations.

OpenAI Function Calling was developed to allow developers to use GPT-3 and GPT-4 more easily and reliably to generate structured output. Before function calling was available, developers had to use regular expressions (RegEx) or prompt engineering to extract the information from the text string that the model generated. This was often difficult and time-consuming, and it could lead to errors.

Function Calling allows developers to define and pass functions to the model as input. The model will then generate output that adheres to the function signature. This makes it much easier for developers to get the needed structured output.

Benefits of Function Calling

There are many benefits to using OpenAI functions; here are a few of the most important ones:

  • Increased flexibility: Function calling allows developers to create more complex and sophisticated applications that require structured output. This is because developers can define their functions and pass them to the model as input. This gives developers more control over the output that the model generates.
  • Improved reliability: Function calling can help to improve the reliability of generating structured output from GPT-3 and GPT-4. The model can generate output that adheres to the function signature. This makes it easier for developers to extract the information they need from the output.
  • Reduced development time: Function calling can help reduce the development time for applications that use GPT-3 and GPT-4. This is because developers do not need to spend time engineering prompts or using regular expressions to extract information from the output.
  • Improved user experience: Function calling can help to improve the user experience of applications that use GPT-3 and GPT-4. This is because the model can generate more structured and easier-to-understand output.

How to use Function Calling in Orquesta Deployments

Orquesta allows you to make use of OpenAI function calling. Since the platform supports OpenAI models, a few currently support Function Calling, which you can enable. You can find the OpenAI model that supports Function Calling in the Model Garden with the tools tag.


Functions consume more tokens, and this is why most teams don't use them in their prompts. You can temporarily disable a function or permanently disable a function to save your tokens.


For this example, we will get the exact weather report for a particular city or country.

You create a new Deployment.

From the screenshot above, two variables were passed into the prompt: “city“ and “country“. The model selected is the openai/gpt-4 which supports Function Calling.

The next thing is to create a function on the sidebar. A function can be created using the + icon in the tools section. The get_current_weather function was created for this tutorial. You can now create a type of enum and add the format of Celsius or Fahrenheit. The location, which is of type string is set to San Francisco, CA, the variable city and country.

On the sidebar, you can also create a new function or edit or rename your functions.

We can create a function that gets the number of days in the weather forecast. Add the type enum and input the format (Celsius or Fahrenheit). For the number of days, we will create a type of integer and set the variable name to num_days. Finally, we can add the type string to the location variable and hit the Save.

Use cases

Here are some use cases for you to consider:

  • Generating creative text formats: You can use these functions to generate different creative text formats, such as poems, code, scripts, musical pieces, emails, letters, etc. This can be useful for various tasks, such as generating marketing copy, writing blog posts, or creating scripts for videos.
  • Translating languages: OpenAI functions can also translate languages. This can be useful for businesses that operate internationally or for individuals who want to translate text from one language to another.
  • Classifying and summarizing text: When working with texts, you may want to classify and summarize them. OpenAI functions can be useful for organizing data, creating content libraries, and generating reports.
  • Answering questions in a comprehensive and informative way: OpenAI functions can be used to answer questions in a comprehensive and informative way. This can be useful for creating chatbots, developing educational tools, and providing customer support.