Overview
TheAutoGen.AzureAIInference package integrates with Azure AI Inference API, providing access to:
- Models deployed on Azure AI Studio
- GitHub Models marketplace
- Azure OpenAI Service
- Various model providers through a unified interface
Installation
Azure AI Studio Setup
1
Deploy a model
Deploy a model in Azure AI Studio and obtain:
- Endpoint URL
- API Key
- Model name
2
Set environment variables
3
Create an agent
GitHub Models
Use models from GitHub Models marketplace:1
Get GitHub token
Create a personal access token from GitHub Settings with appropriate scopes.
2
Set environment variable
3
Create agent with GitHub Models
ChatCompletionsClientAgent
The main agent class for Azure AI Inference:Constructor Parameters
ChatCompletionsClient
required
Azure AI Inference chat client
string
required
Unique identifier for the agent
string
required
Model name (e.g., “gpt-4”, “llama-3.1-8b”)
string
default:"You are a helpful AI assistant"
Instructions defining the agent’s behavior
float
default:"0.7"
Sampling temperature (0.0 = deterministic, 1.0 = creative)
int
default:"1024"
Maximum tokens to generate
int?
Random seed for reproducible outputs
ChatCompletionsResponseFormat?
Response format (e.g., JSON mode)
Available Models
GitHub Models
Models available through GitHub Models marketplace:- OpenAI Models
- Meta Models
- Mistral Models
- Other Models
Basic Usage
Simple conversation example:Streaming Responses
Stream responses for real-time output:Function Calling
Add function calling capabilities:Multi-Agent with Different Models
Combine different models in group chat:JSON Mode
Force JSON responses:Message Support
Supported message types:Configuration Options
Temperature and Randomness
Token Limits
Best Practices
Model Selection
Model Selection
For speed and cost:
- GPT-4o Mini
- Phi-3 Mini
- Mistral Small
- GPT-4o
- Meta Llama 3.1 405B
- Mistral Large
- GPT-4 Turbo
- Meta Llama 3.1 70B
- Mistral Nemo
Cost Optimization
Cost Optimization
Error Handling
Error Handling
Performance
Performance
- Reuse
ChatCompletionsClientinstances - Use streaming for long responses
- Set appropriate token limits
- Consider model capabilities vs. cost
- Use GitHub Models for testing
Environment Variables
string
Your Azure AI endpoint URL
string
Your Azure AI API key
string
GitHub personal access token for GitHub Models
GitHub Models vs Azure AI Studio
GitHub Models
Advantages:
- Free tier for testing
- Easy setup with GitHub token
- Access to multiple model providers
- Great for development
- Rate limits on free tier
- Not for production at scale
Azure AI Studio
Advantages:
- Production-ready
- Enterprise SLAs
- Private deployments
- Custom fine-tuning
- Higher rate limits
- Production applications
- High-volume scenarios
- Enterprise requirements
Next Steps
OpenAI Integration
Use OpenAI models directly
Function Calling
Add tools to your agents
Group Chat
Create multi-agent workflows
Examples
See complete examples