A Symfony bridge that integrates GitHub Copilot AI models into your applications.
- ๐ Easy Integration - Drop-in Symfony bridge for GitHub Copilot
- ๐ฏ Multiple Models - Support for Claude, GPT, Gemini, and more
- ๐ Secure Authentication - Built-in OAuth device flow
- ๐ Console Commands - Ready-to-use CLI commands
Install the bridge using Composer:
composer require akawaka/copilot-bridgeThat's it! The bridge automatically registers its services and commands.
The bridge provides access to multiple AI model families:
use Akawaka\Bridge\Copilot\Copilot;
// Latest Claude models
Copilot::CLAUDE_35_SONNET // claude-3.5-sonnet
Copilot::CLAUDE_37_SONNET // claude-3.7-sonnet
Copilot::CLAUDE_OPUS_4 // claude-opus-4// GPT family models
Copilot::GPT_5 // gpt-5
Copilot::GPT_5_MINI // gpt-5-mini
Copilot::GPT_4O // gpt-4o
Copilot::O3 // o3
Copilot::O3_MINI // o3-mini// Google Gemini models
Copilot::GEMINI_20_FLASH // gemini-2.0-flash-001
Copilot::GEMINI_25_PRO // gemini-2.5-proFirst, authenticate with GitHub Copilot:
php bin/console copilot:authFollow the prompts to complete OAuth authentication.
use Akawaka\Bridge\Copilot\Copilot;
use Akawaka\Bridge\Copilot\PlatformFactory;
use Symfony\Component\HttpClient\HttpClient;
// Create a model instance
$model = new Copilot(Copilot::GPT_5_MINI, [
'temperature' => 0.7,
'max_tokens' => 1000
]);
// Create the platform
$httpClient = HttpClient::create();
$platform = PlatformFactory::create($httpClient);
// Send a prompt
$messages = new MessageBag(Message::ofUser('Hello, how are you?'));
$result = $platform->invoke($model, $messages);
echo $result->asText();# config/services.yaml
services:
App\Service\MyAIService:
arguments:
$copilotAuthService: '@Akawaka\Bridge\Copilot\Auth\CopilotAuthService'
$platformFactory: '@Akawaka\Bridge\Copilot\PlatformFactory'// src/Service/MyAIService.php
use Akawaka\Bridge\Copilot\Auth\CopilotAuthService;
use Akawaka\Bridge\Copilot\Copilot;
use Akawaka\Bridge\Copilot\PlatformFactory;
class MyAIService
{
public function __construct(
private CopilotAuthService $authService,
private PlatformFactory $platformFactory
) {}
public function askQuestion(string $question): string
{
$model = new Copilot(Copilot::CLAUDE_35_SONNET);
$platform = $this->platformFactory->create($this->httpClient);
$messages = new MessageBag(Message::ofUser($question));
$result = $platform->invoke($model, $messages, [
'copilot_access_token' => $this->authService->getAccessToken()
]);
return $result->asText();
}
}The bridge works out-of-the-box with default settings. For custom configuration:
# config/packages/copilot.yaml
copilot:
client_id: 'your-github-app-client-id'
auth_token_expiration: 90 # days
models:
custom_model:
capabilities: ['input_messages', 'output_text']
options:
temperature: 0.5
max_tokens: 2000The bridge provides three console commands:
# Basic authentication
php bin/console copilot:auth
# With custom timeout
php bin/console copilot:auth --timeout=600
# Check existing token first
php bin/console copilot:auth --check-existingphp bin/console copilot:statusphp bin/console copilot:logout$model = new Copilot(Copilot::CLAUDE_35_SONNET, [
'temperature' => 0.8, // Creativity level (0-1)
'max_tokens' => 2000, // Maximum response length
'top_p' => 0.9, // Nucleus sampling
'frequency_penalty' => 0.1, // Reduce repetition
'presence_penalty' => 0.1 // Encourage new topics
]);use Symfony\AI\Platform\Message\MessageBag;
use Symfony\AI\Platform\Message\Message;
$messages = new MessageBag(Message::ofUser('Tell me a story'));
$result = $platform->invoke($model, $messages, [
'stream' => true,
'copilot_access_token' => $accessToken
]);
// Handle streaming response
foreach ($result->stream() as $chunk) {
echo $chunk->getContent();
}use Akawaka\Bridge\Copilot\Exception\CopilotException;
use Akawaka\Bridge\Copilot\Exception\AuthenticationException;
try {
$result = $platform->invoke($model, $messages);
return $result->asText();
} catch (AuthenticationException $e) {
// Handle authentication errors
throw new \RuntimeException('Please run: php bin/console copilot:auth');
} catch (CopilotException $e) {
// Handle other Copilot errors
throw new \RuntimeException('Copilot error: ' . $e->getMessage());
}Different models support different capabilities:
| Model Family | Text Input | Image Input | Streaming | Tool Calling |
|---|---|---|---|---|
| Claude | โ | โ | โ | โ |
| GPT | โ | โ | โ | โ |
| Gemini | โ | โ | โ | โ |
The bridge includes comprehensive tests:
# Run tests
./vendor/bin/phpunit
# Run with coverage
./vendor/bin/phpunit --coverage-html coverage- Fork the repository
- Create your feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'Add feature' - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- ๐ Report Issues
- ๐ฌ Discussions
- Built on top of Symfony AI Platform
Made with โค๏ธ by Franck Matsos