Is it possible to set-up an "Action" instead of a "Function" with the Assistants API?


Function calling vs Actions

As per the Assistants API docs:

Functions: the API allows you to define custom function signatures, with similar behavior as our function calling feature.

Also, as per the “Actions in GPTs” docs:

In addition to using our built-in capabilities, you can also define custom actions by making one or more APIs available to the GPT. Like plugins, actions allow GPTs to integrate external data or interact with the real-world. […]

So, with Custom GPTs you can define an OpenAPI specification which allows you to connect a GPT to a custom API. Then, you can define Endpoints, and your Custom GPT will be able to make a request to those endpoints.

However, the Assistants API seems to not have that option. Am I missing something? Is it possible to define an “Action” for an Assistant to use it?


You can create function that implements an API call. However, the real value in directly specifying “Actions” in Assistants becomes apparent for two primary reasons:

  1. Accessibility for Non-Coders: The ability to craft and set an OpenAPI specification, which then enables the Assistant to handle API calls directly, is a significant advantage. This feature is especially beneficial for individuals who may not have programming skills. It aligns perfectly with OpenAI’s vision of enabling the creation of Custom GPTs without requiring any coding expertise. By removing the barrier of needing to implement the API call through code, it opens up more possibilities for a broader range of users.
  2. Convenience for Coders: For those who are versed in coding, “Actions” provide a straightforward and efficient method to integrate external functionalities. By setting up a backend endpoint and crafting an OpenAPI specification, one can easily integrate this with their Assistant. This approach in Custom GPTs is not only handy but also saves significant time and effort. It eliminates the need to develop a custom Python function for initiating the API call and handling the response, streamlining the entire process.

It seems the primary difference (as you laid out) is that Actions are executed in the OpenAI environment and thus they provide the glue between the model calling a function and then actually executing the function.

The Assistant API (and chat completions) still provide the function call from the model to your code but it’s up to you to receive the function call and then execute the function in your environment.

I’m also interested in leveraging function calling in as easy a way as possible so I developed AIAPI (standing on the shoulders of simpleaichat) which provides the glue between the model making a function call and the execution of that call.

I think this gives you close to an “Action” with the chat completions API as well as most of the capabilities of the Assistant API but with more control.

Hey! You can do many of the same things in the context of actions vs functions. There is fundamentally no difference in how these two operate, though in practice ChatGPT does some of the heavy lifting that an assistant might not do for you.

1 Like

Interesting, but from what I gather, using the AIAPI requires you to fully switch from the OpenAI API and utilize the AIAPI as a wrapper instead. That’s not ideal. Maybe, if Langchain could integrate something like that…

On the contrary, there’s a fundamental difference in how Actions and Functions operate.

Functions are essentially Python functions. This means that you can do pretty much anything, but it requires coding. If your goal is simply to make API calls, you’ll need to write the necessary code to handle the API call request and response.

Actions, on the other hand, are solely for making API calls, and they don’t require any coding - just an OpenAPI specification. If you’re the one developing the API, this is fantastic because you only need to work on backend code. If you’re using a third-party API, it’s even better because you can make use of Actions without having to write any code.

Correct, AIAPI does not have a dependency on the OpenAI SDK. It utilizes the OpenAI API (chat completions) to achieve the same functionality with Assistants API but with the benefits previously discussed.

Curious why you see not utilizing the OpenAI SDK as “not ideal?” Is there something missing or is it just the idea of using an alternative SDK that seems uncomfortable?