Azure Foundry Plugin
This plugin enables you to use Azure OpenAI APIs with Genkit. Azure AI Foundry provides access to powerful OpenAI models (GPT-5, GPT-4, etc.) through Azure’s infrastructure. The plugin supports text generation, embeddings, image generation, text-to-speech, speech-to-text, streaming, tool calling, and multimodal inputs, all with flexible authentication options including API keys, Managed Identity, and Azure CLI.
Installation
Section titled “Installation”Install the plugin in your project with npm or pnpm:
npm install genkitx-azure-openaiThe interface to the models of this plugin is the same as for the OpenAI plugin.
Initialize
Section titled “Initialize”You’ll also need to have an Azure OpenAI instance deployed. You can deploy a version on Azure Portal following this guide.
Once you have your instance running, make sure you have the endpoint and key. You can find them in the Azure Portal, under the “Keys and Endpoint” section of your instance.
You can then define the following environment variables to use the service:
AZURE_OPENAI_ENDPOINT=<YOUR_ENDPOINT>AZURE_OPENAI_API_KEY=<YOUR_KEY>OPENAI_API_VERSION=<YOUR_API_VERSION>Alternatively, you can pass the values directly to the azureOpenAI constructor:
import { azureOpenAI, gpt5 } from 'genkitx-azure-openai';import { genkit } from 'genkit';
const apiVersion = "2024-10-21";
const ai = genkit({ plugins: [ azureOpenAI({ apiKey: "<your_key>", endpoint: "<your_endpoint>", deployment: "<your_embedding_deployment_name", apiVersion, }), // other plugins ], model: gpt5,});If you’re using Azure Managed Identity, you can also pass the credentials directly to the constructor:
import { azureOpenAI, gpt5 } from 'genkitx-azure-openai';import { genkit } from 'genkit';import { DefaultAzureCredential, getBearerTokenProvider,} from "@azure/identity";const apiVersion = "2024-10-21";
const credential = new DefaultAzureCredential();const scope = 'https://cognitiveservices.azure.com/.default';const azureADTokenProvider = getBearerTokenProvider(credential, scope);
const ai = genkit({ plugins: [ azureOpenAI({ azureADTokenProvider, endpoint: "<your_endpoint>", deployment: "<your_embedding_deployment_name", apiVersion, }), // other plugins ], model: gpt5,});Features
Section titled “Features”- Text Generation: Support for GPT models (GPT-5, GPT-4, etc.)
- Embeddings: Support for text-embedding models
- Streaming: Full streaming support for real-time responses
- Tool Calling: Complete function calling capabilities
- Multimodal Support: Support for text + image inputs
- Flexible Authentication: Support for API keys, Managed Identity, and Azure CLI
For more Genkit features like embeddings, structured output, and flows, refer to the Genkit documentation.