Call Your Own API Inside AI Assistant — OpenAI Function Calling
In this article, I’ll explain how we can make a call to external functions and this we will be doing using OpenAI’s Assistant API. If you’re not sure about how to get started with Assistant API, then I would recommend you to go back and have a look at my previous article ‘Create Your First AI Assistant — OpenAI Assistant API’.
Well, as we know that using Assistant API, we can build AI assistants in our own applications with just few sets of instructions.
Before we get started, make sure that you have installed OpenAI, a python library. Let’s get started by grabbing the keys.
Get OpenAI API Key And Organization ID
To get the keys, you need to go to https://openai.com/, login and then grab the keys using highlighted way.
Here we need to grab 2 things — API key and Organization ID
Then set these values in an environment variable:
import os
os.environ["ORGANIZATION_ID"] = "ORG_ID_HERE"
os.environ["OPENAI_API_KEY"] = "API_KEY_HERE"