Adding functions to Completions Extensions REST API

Jai-6363 240 Reputation points
2023-11-17T12:20:30.1166667+00:00

Is there any plan to include functions and function calls in the Completions Extensions REST API?

I am trying to use the function in the API.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
1,431 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ramr-msft 16,216 Reputation points
    2023-11-17T13:24:09.8233333+00:00

    Thanks for the question, Function calling is only supported for the latest chat models (e.g. gpt-35-turbo 0613), where only ChatCompletions API should be used.

    Function calling is now available in Azure OpenAI Service and gives the latest 0613 versions of gpt-35-turbo and gpt-4 the ability to produce structured JSON outputs based on functions that you describe in the request. This provides a native way for these models to formulate API calls and structure data outputs, all based on the functions you specify. It's important to note that while the models can generate these calls, it's up to you to execute them, ensuring you remain in control.

    The latest versions of gpt-35-turbo and gpt-4 have been fine-tuned to learn how to work with functions. If one or more functions are specified in the request, the model will then determine if any of the functions should be called based on the context of the prompt. When the model determines that a function should be called, it will then respond with a JSON object including the arguments for the function.

    At a high level you can break down working with functions into three steps:

    Step #1 – Call the chat completions API with your functions and the user’s input

    Step #2 – Use the model’s response to call your API or function

    Step #3– Call the chat completions API again, including the response from your function to get a final response

    Check out the blog post here for examples of different scenarios where function calling could be helpful and how to use functions safely and securely.

    You can also check out our samples to try out an end-to-end example of function calling.

    0 comments No comments

0 additional answers

Sort by: Most helpful