OpenAIとAzure OpenAIのAPI呼び出しの違い
OpenAIとAzure OpenAIのAPI呼び出しの違いのメモです。
(例としてPandasAIライブラリを使った時)
#OpenAI
import os
import openai
from dotenv import load_dotenv
from pandasai.llm.openai import OpenAI
def load_api():
load_dotenv()
API_KEY = os.environ["OPENAI_API_KEY"]
llm = OpenAI(api_token=API_KEY)
#Azure OpenAI
import os
import openai
from dotenv import load_dotenv
from pandasai.llm.azure_openai import AzureOpenAI
def load_api():
load_dotenv()
API_BASE = os.environ["AZURE_OPENAI_ENDPOINT"]
API_VERSION = os.environ["AZURE_OPENAI_VERSION"]
API_TOKEN = os.environ["AZURE_OPENAI_KEY"]
DEPLOYMENT_NAME=
os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"]
llm = AzureOpenAI(api_base=API_BASE,
api_version=API_VERSION,
api_token=API_TOKEN,
deployment_name=DEPLOYMENT_NAME)