Azure OpenAI
API KEYS​
import os
os.environ["AZURE_API_KEY"] = ""
os.environ["AZURE_API_BASE"] = ""
os.environ["AZURE_API_VERSION"] = ""
Usage​
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 Name | Function Call |
---|---|
gpt-4 | completion('azure/<your deployment name>', messages) |
gpt-4-0314 | completion('azure/<your deployment name>', messages) |
gpt-4-0613 | completion('azure/<your deployment name>', messages) |
gpt-4-32k | completion('azure/<your deployment name>', messages) |
gpt-4-32k-0314 | completion('azure/<your deployment name>', messages) |
gpt-4-32k-0613 | completion('azure/<your deployment name>', messages) |
gpt-3.5-turbo | completion('azure/<your deployment name>', messages) |
gpt-3.5-turbo-0301 | completion('azure/<your deployment name>', messages) |
gpt-3.5-turbo-0613 | completion('azure/<your deployment name>', messages) |
gpt-3.5-turbo-16k | completion('azure/<your deployment name>', messages) |
gpt-3.5-turbo-16k-0613 | completion('azure/<your deployment name>', messages) |