Skip to main content

Installation

npm install @raindrop-ai/azure-openai openai

Quick Start

import { createRaindropAzureOpenAI } from "@raindrop-ai/azure-openai";
import { AzureOpenAI } from "openai";

const raindrop = createRaindropAzureOpenAI({
  writeKey: "rk_...",
  userId: "user-123",
});

const client = new AzureOpenAI({
  endpoint: "https://your-resource.openai.azure.com",
  apiKey: "...",
  apiVersion: "2024-10-21",
});

const wrapped = raindrop.wrap(client);

const response = await wrapped.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "What is the capital of France?" }],
});

console.log(response.choices[0].message.content);
await raindrop.shutdown();

What Gets Traced

  • Chat completions — input messages (user text only), output text, model, token usage (prompt/completion)
  • Errors — captured with error status, re-thrown to caller

Configuration

const raindrop = createRaindropAzureOpenAI({
  writeKey: "rk_...",       // Optional: your Raindrop write key (omit to disable telemetry)
  endpoint: "...",          // Optional: custom Raindrop API endpoint
  userId: "user-123",      // Optional: associate events with a user
  convoId: "convo-456",    // Optional: conversation/thread ID
  debug: false,             // Optional: enable verbose logging
});

Flushing and Shutdown

await raindrop.flush();     // flush pending data
await raindrop.shutdown();  // flush + release resources
Already using the Vercel AI SDK with Azure? The Vercel AI SDK integration automatically traces Azure OpenAI calls when you use the AI SDK’s Azure provider. This integration is for users calling the Azure OpenAI SDK directly.