Azure OpenAI integration
Our JS SDK includes automatic integration with Azure OpenAI.
1
Setup the SDK
npm i openai lunary
2
Monitor AzureOpenAI
With our SDKs, tracking AzureOpenAI calls is super simple.
import { AzureOpenAI } from "openai";
import { monitorOpenAI } from "lunary/openai";
const API_VERSION = process.env.OPENAI_API_VERSION;
const API_KEY = process.env.AZURE_OPENAI_API_KEY;
const AZURE_ENDPOINT = process.env.AZURE_OPENAI_ENDPOINT;
const RESOURCE_NAME = process.env.AZURE_OPENAI_RESOURCE_NAME;
const client = monitorOpenAI(
new AzureOpenAI({
apiVersion: API_VERSION,
endpoint: AZURE_ENDPOINT,
apiKey: API_KEY,
})
);
async function main() {
const chatCompletion = await client.chat.completions.create({
model: RESOURCE_NAME,
messages: [{ role: "user", content: "Say this is a test" }],
});
console.log(chatCompletion.choices[0].message.content);
}
main();