Skip to main content

Azure OpenAI

API KEYS​

import os
os.environ["AZURE_API_KEY"] = ""
os.environ["AZURE_API_BASE"] = ""
os.environ["AZURE_API_VERSION"] = ""

Usage​

Open In Colab

Completion - using .env variables​

from litellm import completion

## set ENV variables
os.environ["AZURE_API_KEY"] = ""
os.environ["AZURE_API_BASE"] = ""
os.environ["AZURE_API_VERSION"] = ""

# azure call
response = completion(
model = "azure/<your_deployment_name>",
messages = [{ "content": "Hello, how are you?","role": "user"}]
)

Completion - using api_key, api_base, api_version​

import litellm

# azure call
response = litellm.completion(
model = "azure/<your deployment name>", # model = azure/<your deployment name>
api_base = "", # azure api base
api_version = "", # azure api version
api_key = "", # azure api key
messages = [{"role": "user", "content": "good morning"}],
)

Azure OpenAI Chat Completion Models​

Model NameFunction Call
gpt-4completion('azure/<your deployment name>', messages)
gpt-4-0314completion('azure/<your deployment name>', messages)
gpt-4-0613completion('azure/<your deployment name>', messages)
gpt-4-32kcompletion('azure/<your deployment name>', messages)
gpt-4-32k-0314completion('azure/<your deployment name>', messages)
gpt-4-32k-0613completion('azure/<your deployment name>', messages)
gpt-3.5-turbocompletion('azure/<your deployment name>', messages)
gpt-3.5-turbo-0301completion('azure/<your deployment name>', messages)
gpt-3.5-turbo-0613completion('azure/<your deployment name>', messages)
gpt-3.5-turbo-16kcompletion('azure/<your deployment name>', messages)
gpt-3.5-turbo-16k-0613completion('azure/<your deployment name>', messages)