1. Go to this page and download the library: Download rodiumai/laravel-sdk 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/ */
rodiumai / laravel-sdk example snippets
use RodiumAI\Facades\RodiumAI;
$response = RodiumAI::model('openai/gpt-4o')
->temperature(0.7)
->maxTokens(300)
->chat('Explain Rodium AI in two sentences.');
echo $response->content;
echo $response->costRodi(); // RODI cost from usage.cost_rodi
use RodiumAI\RodiumAIClient;
$client = new RodiumAIClient(apiKey: getenv('RODIUMAI_API_KEY'));
$response = $client->chat('Hello!');
echo $response->content;
use RodiumAI\Data\ChatMessage;
$messages = [
ChatMessage::system('You are a Laravel assistant.'),
ChatMessage::user('What is a Service Provider?'),
];
$response = RodiumAI::model('openai/gpt-4o')
->temperature(0.5)
->maxTokens(500)
->chat($messages, [
'tools' => [/* OpenAI tool definitions */],
'response_format' => ['type' => 'json_object'],
]);
echo $response->content;
echo $response->costRodi();
$history = [
ChatMessage::user('My name is Amina.'),
ChatMessage::assistant('Nice to meet you, Amina!'),
ChatMessage::user('What is my name?'),
];
$response = RodiumAI::chat($history);
$image = RodiumAI::images([
'model' => 'openai/gpt-image-1',
'prompt' => 'A red fox in the snow',
'size' => '1024x1024',
'quality' => 'medium',
]);
$b64 = $image->firstB64();