PHP code example of iankibet / sdp-ai

1. Go to this page and download the library: Download iankibet/sdp-ai library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iankibet / sdp-ai example snippets


return [
    'default' => 'chatgpt',
    
    'providers' => [
        'chatgpt' => [
            'api_key' => env('CHATGPT_API_KEY'),
        ],
        'claude' => [
            'api_key' => env('CLAUDE_API_KEY'),
        ],
        'deepseek' => [
            'api_key' => env('DEEPSEEK_API_KEY'),
        ],
        'xai' => [
            'api_key' => env('XAI_API_KEY'),
        ],
    ],
];

use SdpAi\Facades\SDPAI;

// Send a message using the default provider
$response = SDPAI::ask('Hello, how are you?');

// Switch provider dynamically
$response = SDPAI::setProvider('claude')->ask('Tell me a joke.');

use SdpAi\SdpAiManager;

class MyController
{
    public function handle(SdpAiManager $sdpAi)
    {
        $response = $sdpAi->setProvider('deepseek')->ask('Explain Quantum Physics.');
    }
}
bash
php artisan vendor:publish --tag="sdpai-config"