symfony/ai-azure-platform
Symfony AI bridge for Microsoft Azure AI: connect to Azure OpenAI and Azure AI Foundry (including Responses API) via Symfony components. Provides integration points to call Azure-hosted models from Symfony AI with links to official Azure references.
$client->complete($prompt, [
'structuredOutput' => [
'schema' => ['type' => 'object', 'properties' => [...]],
],
]);
return cache()->remember("ai_{$prompt}", now()->addHours(1), fn () =>
$client->complete($prompt)
);
| Component | Compatibility Status | Notes |
|---|---|---|
| Laravel 10+ | ✅ Full | Uses Symfony components compatible with Laravel’s PSR standards. |
| PHP 8.1+ | ✅ Full | Minimum PHP version aligns with Symfony AI requirements. |
| Azure OpenAI API | ✅ Full (v0.6.0+) | Uses Azure’s Responses API (v1). |
| Azure Foundry | ✅ Partial (v0.8.0+) | Serverless model deployments supported but less mature than OpenAI. |
| Laravel Queues | ✅ Workaround | Requires custom job classes (no native support). |
| Laravel Validation | ✅ Workaround | Use Validator to parse structured outputs. |
| Laravel Blade | ⚠️ Custom | No native directives; use helpers or custom tags. |
| Laravel Sanctum/Passport | ✅ Indirect | Authenticate API keys via Laravel’s auth systems (e.g., .env + middleware). |
composer and Laravel’s upgrade commands.composer.json to avoid breaking changes:
"symfony/ai-azure-platform": "^0.8",
"symfony/http-client": "^6.4"
config/services.php and use Laravel’s .env for secrets.laravel/envoy or GitHub Actions to sync configs across environments.composer.json script to check for deprecated methods:
"scripts": {
"post-update-cmd": "php artisan ai:check-deprecations"
}
AZURE_OPENAI_API_KEY and endpoint URLs.spatie/laravel-retryable).dd() or Xdebug to inspect response schemas.| Issue Type | Support Level | Escalation Path |
|---|---|---|
| Azure API Errors | High | Azure Status Page → Microsoft Support |
| Symfony AI Bugs | Medium | GitHub Issues → Symfony Slack |
| Laravel Integration | Low | Internal docs → Feature Request |
GenerateAiResponse::dispatch($prompt)->onQueue('ai');
semaphore package to limit concurrent AI calls:
use Spatie\Semaphore\Semaphore;
if (Semaphore::acquire('ai_calls', 5)) {
$response = $client->complete($prompt);
Semaphore::release('ai_calls');
}
Provider abstraction to route to cheaper models (e.g., text-davinci-003 vs. gpt-4).public function handle($request, Closure $next) {
$response = $next($request);
$tokens = $response->getTokenCount(); // Custom logic
Log::info("AI tokens used: {$tokens}");
return $response;
}
| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| Azure API Outage | High (No AI responses) | Implement multi-provider fallback (e.g., OpenAI) via Provider abstraction. |
| Rate Limit Exceeded (429) | Medium (Delayed responses) | Use spatie/laravel-retryable with exponential backoff. |
| Authentication Failure (401) | High (All AI calls blocked) | Monitor key rotation and use Laravel’s env() caching with short TTL. |
| Structured Output Parsing Error | Medium (Data corruption) | Validate responses with Laravel’s Validator and log malformed payloads. |
| Laravel Cache Failure | Low (No cached responses) | Fallback to direct API calls with degraded performance. |
| PHP/Symfony Version Conflict | High (Integration breaks) | Pin versions in composer.json and test upgrades in staging. |
Onboarding Resources:
README.md in your repo covering:
.env)..env.php artisan tinker.Training Path:
Knowledge Transfer:
ai:generate Artisan command).How can I help you explore Laravel packages today?