{ "cells": [ { "cell_type": "markdown", "id": "8b538d3a", "metadata": {}, "source": [ "# `AzureOpenAIClient` client\n", "\n", "This notebook demonstrates how to instantiate the AzureOpenAIClient object. AzureOpenAIClient is a subclass of the BaseLLMClient Abstract class.\n", "\n", "For more thorough look at AzureOpenAIClient's structure, look to the [AzureOpenAIClient](../../../docs/build/html/_autosummary/ai_sentinel.llm.AzureOpenAIClient.html) or [BaseLLMClient](../../../docs/build/html/_autosummary/ai_sentinel.llm.BaseLLMClient.html) API reference. " ] }, { "cell_type": "markdown", "id": "08c02203", "metadata": {}, "source": [ "### Setting up the Client\n", "To set up the Azure OpenAI Client there are 4 required parameters:\n", "- your project Azure OpenAI API Key \n", "- a valid OpenAI model\n", "- the api version of your project\n", "- the endpoint to your project\n", "\n", "All of this can be set up and found at the [Azure AI Foundry](https://ai.azure.com/)" ] }, { "cell_type": "code", "execution_count": null, "id": "dd16785c", "metadata": {}, "outputs": [], "source": [ "from ai_sentinel import AzureOpenAIClient\n", "\n", "# Initialize an Azure OpenAI LLM Client\n", "client = AzureOpenAIClient(\n", " api_key=\"YOUR_API_KEY\",\n", " model=\"gpt-4o-mini\",\n", " api_version=\"2024-02-01\",\n", " azure_endpoint=\"https://your-resource.openai.azure.com/\"\n", ")" ] }, { "cell_type": "markdown", "id": "506bcf2e", "metadata": {}, "source": [ "Once the Client is set up, all further usage in the code will be with the [ToxicityGuard](example_notebooks/api_examples/guards/basic_usage.ipynb)" ] }, { "cell_type": "markdown", "id": "b918e04e", "metadata": {}, "source": [ "## Environment variable names\n", "The following is the recommended format to follow for key naming convention when working with Azure OpenAI" ] }, { "cell_type": "code", "execution_count": null, "id": "5a42cd56", "metadata": {}, "outputs": [], "source": [ "AZURE_API_KEY='YOUR_API_KEY'\n", "AZURE_API_BASE='https://your-resource.openai.azure.com/'\n", "AZURE_API_VERSION='2024-12-01-preview'" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }