Azure OpenAI
Using API Key
-
Create an account on Azure OpenAI and get your API key.
-
Create a new deployment of the model and get the deployment name.
-
Add the following to your
taskweaver_config.json
file:{
"llm.api_base":"YOUR_AOAI_ENDPOINT", // in the format of https://<my-resource>.openai.azure.com"
"llm.api_key":"YOUR_API_KEY",
"llm.api_type":"azure",
"llm.model":"gpt-4-1106-preview", // this is known as deployment_name in Azure OpenAI
"llm.response_format": "json_object",
"llm.azure.api_version": "2024-06-01"
}infoFor model versions or after
1106
,llm.response_format
can be set tojson_object
. However, for the earlier models, which do not support JSON response explicitly,llm.response_format
should be set tonull
. -
Start TaskWeaver and chat with TaskWeaver.
You can refer to the Quick Start for more details.
Using Entra Authentication
-
Create an account on Azure OpenAI and assign the proper Azure RBAC Role to your account (or service principal).
-
Create a new deployment of the model and get the deployment name.
-
Add the following to your
taskweaver_config.json
file:{
"llm.api_base":"YOUR_AOAI_ENDPOINT", // in the format of https://<my-resource>.openai.azure.com"
"llm.api_type":"azure_ad",
"llm.model":"gpt-4-1106-preview", // this is known as deployment_name in Azure OpenAI
"llm.response_format": "json_object",
"llm.azure_ad.api_version": "2024-06-01",
"llm.azure_ad.aad_auth_mode": "default_azure_credential"
} -
Install extra dependencies:
pip install azure-identity
-
Optionally configure additional environment variables or dependencies for the specifying authentication method:
Internally, authentication is handled by the
DefaultAzureCredential
class from theazure-identity
package. It would try to authenticate using a series of methods depending on the availability in current running environment (such as environment variables, managed identity, etc.). You can refer to the official documentation for more details.For example, you can specify different environment variables to control the authentication method:
-
Authenticating with AzureCLI (recommended for local development):
Install AzureCLI and ensure
az
is available in your PATH. Then run the following command to login:az login
-
Authenticating with Managed Identity (recommended for Azure environment):
If you are running TaskWeaver on Azure, you can use Managed Identity for authentication. You can check the document for specific Azure services on how to enable Managed Identity.
When using user assigned managed identity, you can set the following environment variable to specify the client ID of the managed identity:
export AZURE_CLIENT_ID="YOUR_CLIENT_ID"
-
Authenticating with Service Principal:
You can follow the docs in the official documentation to specify the environment variables for Service Principal authentication.
-
-
Start TaskWeaver and chat with TaskWeaver.