- Set the following environment variables -
Install OpenAI addon
Usage
To use Azure Managed Identity, you can use something similar to the following code snippet -
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
AZURE_OPENAI_API_INSTANCE_NAME=<YOUR_INSTANCE_NAME>
AZURE_OPENAI_API_DEPLOYMENT_NAME=<YOUR_DEPLOYMENT_NAME>
AZURE_OPENAI_API_VERSION="2024-02-01" #or a newer version
AZURE_OPENAI_API_KEY=<YOUR_KEY>
npm install @llm-tools/embedjs-openai
import { RAGApplicationBuilder } from '@llm-tools/embedjs';
import { AzureOpenAi } from '@llm-tools/embedjs-openai';
const app = await new RAGApplicationBuilder()
.setModel(new AzureOpenAi({ model: "gpt-4o" }))
import {
DefaultAzureCredential,
getBearerTokenProvider,
} from "@azure/identity";
import { AzureOpenAi } from '@llm-tools/embedjs-openai';
const credentials = new DefaultAzureCredential();
const azureADTokenProvider = getBearerTokenProvider(
credentials,
"https://cognitiveservices.azure.com/.default"
);
const app = new AzureOpenAI({
azureADTokenProvider,
azureOpenAIApiInstanceName: "<your_instance_name>",
azureOpenAIApiDeploymentName: "<your_deployment_name>",
azureOpenAIApiVersion: "<api_version>",
});
Was this page helpful?
