{"id":42365196,"url":"https://github.com/genkit-ai/azure-foundry-go-plugin","last_synced_at":"2026-04-04T22:04:38.174Z","repository":{"id":327293604,"uuid":"1108724920","full_name":"genkit-ai/azure-foundry-go-plugin","owner":"genkit-ai","description":"Genkit Go plugin for Azure AI Foundry","archived":false,"fork":false,"pushed_at":"2026-04-02T13:02:54.000Z","size":520,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-02T21:46:09.825Z","etag":null,"topics":["genkit","genkit-plugin","go","golang"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/xavidop/genkit-azure-foundry-go","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/genkit-ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"xavidop","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-12-02T20:45:15.000Z","updated_at":"2026-04-02T13:02:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/genkit-ai/azure-foundry-go-plugin","commit_stats":null,"previous_names":["xavidop/genkit-azure-foundry-go","genkit-ai/azure-foundry-go-plugin"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/genkit-ai/azure-foundry-go-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fazure-foundry-go-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fazure-foundry-go-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fazure-foundry-go-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fazure-foundry-go-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genkit-ai","download_url":"https://codeload.github.com/genkit-ai/azure-foundry-go-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genkit-ai%2Fazure-foundry-go-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31416430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["genkit","genkit-plugin","go","golang"],"created_at":"2026-01-27T18:12:54.760Z","updated_at":"2026-04-04T22:04:38.166Z","avatar_url":"https://github.com/genkit-ai.png","language":"Go","funding_links":["https://github.com/sponsors/xavidop"],"categories":[],"sub_categories":[],"readme":"# Azure AI Foundry Plugin for Genkit Go\n\nA comprehensive Azure AI Foundry plugin for Genkit Go that provides text generation and chat capabilities using Azure OpenAI and other models available through Azure AI Foundry.\n\n\u003c!-- TOC --\u003e\n\n- [Azure AI Foundry Plugin for Genkit Go](#azure-ai-foundry-plugin-for-genkit-go)\n\t- [Features](#features)\n\t- [Supported Models](#supported-models)\n\t\t- [Text Generation Models (with Tool Calling Support)](#text-generation-models-with-tool-calling-support)\n\t- [Installation](#installation)\n\t- [Quick Start](#quick-start)\n\t\t- [Initialize the Plugin](#initialize-the-plugin)\n\t\t- [Define Models and Generate Text](#define-models-and-generate-text)\n\t- [Configuration Options](#configuration-options)\n\t\t- [Available Configuration](#available-configuration)\n\t- [Azure Setup and Authentication](#azure-setup-and-authentication)\n\t\t- [Getting Your Endpoint and API Key](#getting-your-endpoint-and-api-key)\n\t\t- [Authentication Methods](#authentication-methods)\n\t\t\t- [1. API Key Authentication (Quick Start)](#1-api-key-authentication-quick-start)\n\t\t\t- [2. Azure Default Credential (Recommended for Production)](#2-azure-default-credential-recommended-for-production)\n\t\t\t- [3. Managed Identity (Azure Deployments)](#3-managed-identity-azure-deployments)\n\t\t\t- [4. Client Secret Credential (Service Principal)](#4-client-secret-credential-service-principal)\n\t\t\t- [5. Azure CLI Credential (Local Development)](#5-azure-cli-credential-local-development)\n\t\t- [Model Deployments](#model-deployments)\n\t- [Examples Directory](#examples-directory)\n\t\t- [Running Examples](#running-examples)\n\t- [Features in Detail](#features-in-detail)\n\t\t- [🔧 Tool Calling (Function Calling)](#-tool-calling-function-calling)\n\t\t- [🖼️ Multimodal Support (Vision)](#️-multimodal-support-vision)\n\t\t- [📡 Streaming](#-streaming)\n\t\t- [💬 Multi-turn Conversations](#-multi-turn-conversations)\n\t\t- [🔢 Embeddings](#-embeddings)\n\t\t- [🎨 Image Generation](#-image-generation)\n\t\t- [🗣️ Text-to-Speech](#️-text-to-speech)\n\t\t- [🎙️ Speech-to-Text](#️-speech-to-text)\n\t- [Troubleshooting](#troubleshooting)\n\t\t- [Common Issues](#common-issues)\n\t- [Contributing](#contributing)\n\t- [License](#license)\n\t- [Acknowledgments](#acknowledgments)\n\n\u003c!-- /TOC --\u003e\n\n## Features\n\n- **Text Generation**: Support for GPT-5, GPT-5 mini, GPT-4o, GPT-4o mini, GPT-4 Turbo, GPT-4, and GPT-3.5 Turbo models\n- **Embeddings**: Support for text-embedding-ada-002, text-embedding-3-small, and text-embedding-3-large models\n- **Image Generation**: Support for creating images from text prompts\n- **Text-to-Speech**: Convert text to natural-sounding speech with multiple voices\n- **Speech-to-Text**: Transcribe audio to text using with subtitle support\n- **Streaming**: Full streaming support for real-time responses\n- **Tool Calling**: Complete function calling capabilities for GPT-4 and GPT-3.5-turbo models\n- **Multimodal Support**: Support for text + image inputs (vision models like GPT-5, GPT-4o and GPT-4 Turbo)\n- **Multi-turn Conversations**: Full support for chat history and context management\n- **Type Safety**: Robust type conversion and schema validation\n- **Flexible Authentication**: Support for API keys, Azure Default Credential, and custom token credentials\n\n## Supported Models\n\n### Text Generation Models (with Tool Calling Support)\n\n- **GPT-5**: Latest advanced model (check Azure for availability)\n- **GPT-5 mini**: Smaller, faster version of GPT-5\n- **GPT-4o**: multimodal model with vision capabilities\n- **GPT-4o mini**: Smaller, faster version of GPT-4o\n- **GPT-4 Turbo**: High-performance GPT-4 with vision support\n- **GPT-4**: Standard GPT-4 model\n- **GPT-3.5 Turbo**: Fast and cost-effective model\n\nAll GPT-5, GPT-4 and GPT-3.5-turbo models support function calling (tools).\n\n## Installation\n\n```bash\ngo get github.com/xavidop/genkit-azure-foundry-go\n```\n\n## Quick Start\n\n### Initialize the Plugin\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/firebase/genkit/go/ai\"\n\t\"github.com/firebase/genkit/go/genkit\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\n\t// Initialize Azure AI Foundry plugin\n\tazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\t\tEndpoint: os.Getenv(\"AZURE_OPENAI_ENDPOINT\"),\n\t\tAPIKey:   os.Getenv(\"AZURE_OPENAI_API_KEY\"),\n\t}\n\n\t// Initialize Genkit\n\tg := genkit.Init(ctx,\n\t\tgenkit.WithPlugins(azurePlugin),\n\t\tgenkit.WithDefaultModel(\"azureaifoundry/gpt-5\"),\n\t)\n\n\t// Optional: Define common models for easy access\n\tazureaifoundry.DefineCommonModels(azurePlugin, g)\n\n\tlog.Println(\"Starting basic Azure AI Foundry example...\")\n\n\t// Example: Generate text (basic usage)\n\tresponse, err := genkit.Generate(ctx, g,\n\t\tai.WithPrompt(\"What are the key benefits of using Azure AI Foundry?\"),\n\t)\n\tif err != nil {\n\t\tlog.Printf(\"Error: %v\", err)\n\t} else {\n\t\tlog.Printf(\"Response: %s\", response.Text())\n\t}\n}\n```\n\n### Define Models and Generate Text\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/firebase/genkit/go/ai\"\n\t\"github.com/firebase/genkit/go/genkit\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\n\tazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\t\tEndpoint: \"https://your-resource.openai.azure.com/\",\n\t\tAPIKey:   \"your-api-key\",\n\t}\n\n\tg := genkit.Init(ctx,\n\t\tgenkit.WithPlugins(azurePlugin),\n\t)\n\n\t// Define a GPT-5 model (use your deployment name)\n\tgpt5Model := azurePlugin.DefineModel(g, azureaifoundry.ModelDefinition{\n\t\tName:          \"gpt-5\", // Your deployment name in Azure\n\t\tType:          \"chat\",\n\t\tSupportsMedia: true,\n\t}, nil)\n\n\t// Generate text\n\tresponse, err := genkit.Generate(ctx, g,\n\t\tai.WithModel(gpt4Model),\n\t\tai.WithMessages(ai.NewUserMessage(\n\t\t\tai.NewTextPart(\"Explain quantum computing in simple terms.\"),\n\t\t)),\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Println(response.Text())\n}\n```\n\n## Configuration Options\n\nThe plugin supports various configuration options:\n\n```go\nazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\tEndpoint:   \"https://your-resource.openai.azure.com/\",\n\tAPIKey:     \"your-api-key\",              // Use API key\n\t// OR use Azure credential\n\t// Credential: azidentity.NewDefaultAzureCredential(),\n\tAPIVersion: \"2024-02-15-preview\",        // Optional\n}\n```\n\n### Available Configuration\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `Endpoint` | `string` | *required* | Azure OpenAI endpoint URL |\n| `APIKey` | `string` | \"\" | API key for authentication |\n| `Credential` | `azcore.TokenCredential` | `nil` | Azure credential (alternative to API key) |\n| `APIVersion` | `string` | Latest | API version to use |\n\n## Azure Setup and Authentication\n\n### Getting Your Endpoint and API Key\n\n1. Go to [Azure Portal](https://portal.azure.com)\n2. Navigate to your Azure OpenAI resource\n3. Go to \"Keys and Endpoint\" section\n4. Copy your endpoint URL and API key\n\n### Authentication Methods\n\nThe plugin supports multiple authentication methods to suit different deployment scenarios:\n\n#### 1. API Key Authentication (Quick Start)\n\nBest for: Development, testing, and simple scenarios\n\n```bash\nexport AZURE_OPENAI_ENDPOINT=\"https://your-resource.openai.azure.com/\"\nexport AZURE_OPENAI_API_KEY=\"your-api-key\"\n```\n\n```go\nimport (\n\t\"os\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\nazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\tEndpoint: os.Getenv(\"AZURE_OPENAI_ENDPOINT\"),\n\tAPIKey:   os.Getenv(\"AZURE_OPENAI_API_KEY\"),\n}\n```\n\n#### 2. Azure Default Credential (Recommended for Production)\n\nBest for: Production deployments, Azure-hosted applications\n\n`DefaultAzureCredential` automatically tries multiple authentication methods in the following order:\n1. **Environment variables** (AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID)\n2. **Managed Identity** (when deployed to Azure)\n3. **Azure CLI** credentials (for local development)\n4. **Azure PowerShell** credentials\n5. **Interactive browser** authentication\n\n```bash\n# Required environment variables\nexport AZURE_OPENAI_ENDPOINT=\"https://your-resource.openai.azure.com/\"\nexport AZURE_TENANT_ID=\"your-tenant-id\"\n\n# Optional: For service principal authentication\nexport AZURE_CLIENT_ID=\"your-client-id\"\nexport AZURE_CLIENT_SECRET=\"your-client-secret\"\n```\n\n```go\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"github.com/Azure/azure-sdk-for-go/sdk/azidentity\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\nfunc main() {\n\tendpoint := os.Getenv(\"AZURE_OPENAI_ENDPOINT\")\n\ttenantID := os.Getenv(\"AZURE_TENANT_ID\")\n\n\t// Create DefaultAzureCredential\n\tcredential, err := azidentity.NewDefaultAzureCredential(\u0026azidentity.DefaultAzureCredentialOptions{\n\t\tTenantID: tenantID,\n\t})\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"ERROR: %s\\n\", err)\n\t\treturn\n\t}\n\n\t// Initialize plugin with credential\n\tazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\t\tEndpoint:   endpoint,\n\t\tCredential: credential,\n\t}\n\n\t// Use the plugin with Genkit...\n}\n```\n\n#### 3. Managed Identity (Azure Deployments)\n\nBest for: Applications deployed to Azure (App Service, Container Apps, VMs, AKS)\n\nWhen deployed to Azure, Managed Identity provides authentication without storing credentials:\n\n```go\nimport (\n\t\"os\"\n\t\"github.com/Azure/azure-sdk-for-go/sdk/azidentity\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\nfunc main() {\n\tendpoint := os.Getenv(\"AZURE_OPENAI_ENDPOINT\")\n\n\t// Use Managed Identity\n\tcredential, err := azidentity.NewManagedIdentityCredential(nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\t\tEndpoint:   endpoint,\n\t\tCredential: credential,\n\t}\n}\n```\n\n#### 4. Client Secret Credential (Service Principal)\n\nBest for: CI/CD pipelines, automated deployments\n\n```bash\nexport AZURE_OPENAI_ENDPOINT=\"https://your-resource.openai.azure.com/\"\nexport AZURE_TENANT_ID=\"your-tenant-id\"\nexport AZURE_CLIENT_ID=\"your-client-id\"\nexport AZURE_CLIENT_SECRET=\"your-client-secret\"\n```\n\n```go\nimport (\n\t\"os\"\n\t\"github.com/Azure/azure-sdk-for-go/sdk/azidentity\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\nfunc main() {\n\tendpoint := os.Getenv(\"AZURE_OPENAI_ENDPOINT\")\n\ttenantID := os.Getenv(\"AZURE_TENANT_ID\")\n\tclientID := os.Getenv(\"AZURE_CLIENT_ID\")\n\tclientSecret := os.Getenv(\"AZURE_CLIENT_SECRET\")\n\n\tcredential, err := azidentity.NewClientSecretCredential(tenantID, clientID, clientSecret, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\t\tEndpoint:   endpoint,\n\t\tCredential: credential,\n\t}\n}\n```\n\n#### 5. Azure CLI Credential (Local Development)\n\nBest for: Local development with Azure CLI installed\n\n```bash\n# Login to Azure CLI first\naz login\n\nexport AZURE_OPENAI_ENDPOINT=\"https://your-resource.openai.azure.com/\"\n```\n\n```go\nimport (\n\t\"os\"\n\t\"github.com/Azure/azure-sdk-for-go/sdk/azidentity\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\nfunc main() {\n\tendpoint := os.Getenv(\"AZURE_OPENAI_ENDPOINT\")\n\n\t// Use Azure CLI credentials\n\tcredential, err := azidentity.NewAzureCLICredential(nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tazurePlugin := \u0026azureaifoundry.AzureAIFoundry{\n\t\tEndpoint:   endpoint,\n\t\tCredential: credential,\n\t}\n}\n```\n\n### Model Deployments\n\nImportant: The `Name` in `ModelDefinition` should match your **deployment name** in Azure, not the model name. For example:\n\n- If you deployed `gpt-5` with deployment name `my-gpt5-deployment`, use `\"my-gpt5-deployment\"`\n- If you deployed `gpt-4o` with deployment name `gpt-4o`, use `\"gpt-4o\"`\n\n## Examples Directory\n\nThe repository includes comprehensive examples:\n\n- **`examples/basic/`** - Simple text generation\n- **`examples/streaming/`** - Real-time streaming responses\n- **`examples/chat/`** - Multi-turn conversation with context\n- **`examples/embeddings/`** - Text embeddings generation\n- **`examples/tool_calling/`** - Function calling with multiple tools\n- **`examples/vision/`** - Multimodal image analysis\n- **`examples/image_generation/`** - Generate images\n- **`examples/text_to_speech/`** - Convert text to speech\n- **`examples/speech_to_text/`** - Transcribe audio to text\n\n### Running Examples\n\n```bash\n# Set environment variables\nexport AZURE_OPENAI_ENDPOINT=\"https://your-resource.openai.azure.com/\"\nexport AZURE_OPENAI_API_KEY=\"your-api-key\"\n\n# Run basic example\ncd examples/basic\ngo run main.go\n\n# Run streaming example\ncd ../streaming\ngo run main.go\n\n# Run chat example\ncd ../chat\ngo run main.go\n\n# Run tool calling example\ncd ../tool_calling\ngo run main.go\n\n# Run vision example\ncd ../vision\ngo run main.go\n\n# Run image generation example\ncd ../image_generation\ngo run main.go\n\n# Run text-to-speech example\ncd ../text_to_speech\ngo run main.go\n\n# Run speech-to-text example (requires audio files)\ncd ../speech_to_text\ngo run main.go\n```\n\n## Features in Detail\n\n### 🔧 Tool Calling (Function Calling)\n\n```go\n// Define a tool\nweatherTool := genkit.DefineTool(g, \"get_weather\",\n\t\"Get current weather\",\n\tfunc(ctx *ai.ToolContext, input struct {\n\t\tLocation string `json:\"location\"`\n\t\tUnit     string `json:\"unit,omitempty\"`\n\t}) (string, error) {\n\t\treturn getWeather(input.Location, input.Unit)\n\t},\n)\n\n// Use the tool\nresponse, err := genkit.Generate(ctx, g,\n\tai.WithModel(gpt4Model),\n\tai.WithTools(weatherTool),\n\tai.WithPrompt(\"What's the weather in San Francisco?\"),\n)\n```\n\n### 🖼️ Multimodal Support (Vision)\n\nGPT-5 and GPT-4o support image inputs:\n\n```go\nresponse, err := genkit.Generate(ctx, g,\n\tai.WithModel(gpt5Model),\n\tai.WithMessages(ai.NewUserMessage(\n\t\tai.NewTextPart(\"What's in this image?\"),\n\t\tai.NewMediaPart(\"image/jpeg\", imageDataURL),\n\t)),\n)\n```\n\n### 📡 Streaming\n\n```go\nstreamCallback := func(ctx context.Context, chunk *ai.ModelResponseChunk) error {\n\tfor _, part := range chunk.Content {\n\t\tif part.IsText() {\n\t\t\tfmt.Print(part.Text)\n\t\t}\n\t}\n\treturn nil\n}\n\nresponse, err := genkit.Generate(ctx, g,\n\tai.WithModel(gpt4Model),\n\tai.WithPrompt(\"Tell me a story\"),\n\tai.WithStreaming(streamCallback),\n)\n```\n\n### 💬 Multi-turn Conversations\n\n```go\n// First message\nresponse1, _ := genkit.Generate(ctx, g,\n\tai.WithModel(gpt4Model),\n\tai.WithMessages(\n\t\tai.NewSystemMessage(ai.NewTextPart(\"You are a helpful assistant.\")),\n\t\tai.NewUserTextMessage(\"What is Azure?\"),\n\t),\n)\n\n// Follow-up message with context\nresponse2, _ := genkit.Generate(ctx, g,\n\tai.WithModel(gpt4Model),\n\tai.WithMessages(\n\t\tai.NewSystemMessage(ai.NewTextPart(\"You are a helpful assistant.\")),\n\t\tai.NewUserTextMessage(\"What is Azure?\"),\n\t\tresponse1.Message, // Previous assistant message\n\t\tai.NewUserTextMessage(\"What are its key services?\"),\n\t),\n)\n```\n\n### 🔢 Embeddings\n\n```go\nimport (\n\t\"github.com/firebase/genkit/go/ai\"\n\tazureaifoundry \"github.com/xavidop/genkit-azure-foundry-go\"\n)\n\n// Define an embedder (use your deployment name)\nembedder := azurePlugin.DefineEmbedder(g, \"text-embedding-3-small\")\n\n// Or use common embedders helper\nembedders := azureaifoundry.DefineCommonEmbedders(azurePlugin, g)\n\n// Generate embeddings\nresponse, err := genkit.Embed(ctx, g,\n\tai.WithEmbedder(embedder),\n\tai.WithEmbedText(\"Azure AI Foundry provides powerful AI capabilities\"),\n)\n\nif err != nil {\n\tlog.Fatal(err)\n}\n\n// Access the embedding vector\nembedding := response.Embeddings[0].Embedding // []float32\nlog.Printf(\"Embedding dimensions: %d\", len(embedding))\n```\n\n### 🎨 Image Generation\n\nGenerate images with DALL-E models using the standard `genkit.Generate()` method:\n\n```go\n// Define DALL-E model\ndallE3 := azurePlugin.DefineModel(g, azureaifoundry.ModelDefinition{\n\tName: azureaifoundry.ModelDallE3,\n\tType: \"chat\",\n}, nil)\n\n// Generate image\nresponse, err := genkit.Generate(ctx, g,\n\tai.WithModel(dallE3),\n\tai.WithPrompt(\"A serene landscape with mountains at sunset\"),\n\tai.WithConfig(map[string]interface{}{\n\t\t\"quality\": \"hd\",\n\t\t\"size\":    \"1024x1024\",\n\t\t\"style\":   \"vivid\",\n\t}),\n)\n\nif err != nil {\n\tlog.Fatal(err)\n}\n\nlog.Printf(\"Image URL: %s\", response.Text())\n```\n\n### 🗣️ Text-to-Speech\n\nConvert text to speech using the standard `genkit.Generate()` method:\n\n```go\nimport \"encoding/base64\"\n\n// Define TTS model\nttsModel := azurePlugin.DefineModel(g, azureaifoundry.ModelDefinition{\n\tName: azureaifoundry.ModelTTS1HD,\n\tType: \"chat\",\n}, nil)\n\n// Generate speech\nresponse, err := genkit.Generate(ctx, g,\n\tai.WithModel(ttsModel),\n\tai.WithPrompt(\"Hello! Welcome to Azure AI Foundry.\"),\n\tai.WithConfig(map[string]interface{}{\n\t\t\"voice\":           \"nova\",\n\t\t\"response_format\": \"mp3\",\n\t\t\"speed\":           1.5,\n\t}),\n)\n\nif err != nil {\n\tlog.Fatal(err)\n}\n\n// Decode base64 audio and save file\naudioData, _ := base64.StdEncoding.DecodeString(response.Text())\nos.WriteFile(\"output.mp3\", audioData, 0644)\n```\n\n### 🎙️ Speech-to-Text\n\nTranscribe audio to text using the standard `genkit.Generate()` method:\n\n```go\nimport \"encoding/base64\"\n\n// Define Whisper model with media support (required for audio input)\nwhisperModel := azurePlugin.DefineModel(g, azureaifoundry.ModelDefinition{\n\tName:          azureaifoundry.ModelWhisper1,\n\tType:          \"chat\",\n\tSupportsMedia: true, // Required for media parts (audio)\n}, nil)\n\n// Read and encode audio file\naudioData, _ := os.ReadFile(\"audio.mp3\")\nbase64Audio := base64.StdEncoding.EncodeToString(audioData)\n\n// Transcribe audio\nresponse, err := genkit.Generate(ctx, g,\n\tai.WithModel(whisperModel),\n\tai.WithMessages(ai.NewUserMessage(\n\t\tai.NewMediaPart(\"audio/mp3\", \"data:audio/mp3;base64,\"+base64Audio),\n\t)),\n\tai.WithConfig(map[string]interface{}{\n\t\t\"language\": \"en\",\n\t}),\n)\n\nif err != nil {\n\tlog.Fatal(err)\n}\n\nlog.Printf(\"Transcription: %s\", response.Text())\n```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **\"Endpoint is required\" Error**\n   - Verify `AZURE_OPENAI_ENDPOINT` is set correctly\n   - Ensure the endpoint URL includes `https://` and trailing `/`\n\n2. **\"Deployment not found\" Error**\n   - Check that the deployment name in your code matches the actual deployment name in Azure\n   - Verify the model is deployed in your Azure OpenAI resource\n\n3. **Authentication Errors**\n   - Ensure your API key is correct\n   - Check that your Azure subscription is active\n   - Verify network connectivity to Azure\n\n4. **Rate Limit Errors**\n   - Implement exponential backoff retry logic\n   - Consider upgrading to higher rate limits\n   - Distribute requests across time\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Follow [Conventional Commits](https://conventionalcommits.org/) format\n4. Commit your changes (`git commit -m 'feat: add amazing feature'`)\n5. Push to the branch (`git push origin feature/amazing-feature`)\n6. Open a Pull Request\n\n## License\n\nApache 2.0 - see [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Genkit team for the excellent Go framework\n- Azure AI team for the comprehensive AI platform\n- The open source community for inspiration and feedback\n\n---\n\n**Built with ❤️ for the Genkit Go community**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenkit-ai%2Fazure-foundry-go-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenkit-ai%2Fazure-foundry-go-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenkit-ai%2Fazure-foundry-go-plugin/lists"}