Azure OpenAI Integration

Secure your Azure OpenAI deployments with TalonAI.

Proxy Mode

import { AzureOpenAI } from 'openai';

const client = new AzureOpenAI({
  apiKey: process.env.AZURE_OPENAI_API_KEY,
  baseURL: 'https://api.talonai.io/v1/proxy/azure',
  defaultHeaders: {
    'X-TalonAI-Key': process.env.TALONAI_API_KEY,
    'X-Azure-Resource': 'your-resource-name',
    'X-Azure-Deployment': 'your-deployment-name',
  },
});

const response = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: userInput }],
});

SDK Integration

import { TalonAI } from '@talonai/sdk';
import { AzureOpenAI } from 'openai';

const talon = new TalonAI();
const azure = new AzureOpenAI({
  endpoint: process.env.AZURE_OPENAI_ENDPOINT,
  apiKey: process.env.AZURE_OPENAI_API_KEY,
  apiVersion: '2024-02-01',
});

async function chat(userMessage: string) {
  const analysis = await talon.analyze({ content: userMessage });

  if (!analysis.isSafe) {
    throw new Error('Blocked');
  }

  const response = await azure.chat.completions.create({
    model: 'gpt-4',
    messages: [{ role: 'user', content: userMessage }],
  });

  return response.choices[0].message.content;
}

Configuration

Required environment variables:

AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_KEY=your-azure-api-key
TALONAI_API_KEY=your-talonai-key

Enterprise Features

  • Private endpoint support
  • Managed identity authentication
  • Azure AD integration
  • Compliance logging to Azure Monitor