1. Go to this page and download the library: Download modfin/bellman 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/ */
modfin / bellman example snippets
use Bellman\Client;
use Bellman\Models\Anthropic;
use Bellman\Models\OpenAI;
$bellman = new Client(getenv('BELLMAN_URL'), 'my-app', getenv('BELLMAN_TOKEN'));
// or, with a combined key: Client::fromKey(getenv('BELLMAN_URL'), getenv('BELLMAN_KEY'))
$res = $bellman->generator()
->model(OpenAI::GenModel_gpt4o_mini())
->prompt('What company made you?');
echo $res->text(); // OpenAI
$llm = $bellman->generator()
->model(Anthropic::GenModel_5_5_sonnet_latest())
->system('You are a helpful assistant. Answer briefly.')
->temperature(0.2)
->maxTokens(1000);
$a = $llm->prompt('Why is the sky blue?');
$b = $llm->temperature(1.0)->prompt('Write a haiku about Stockholm.'); // $llm is unchanged
use Bellman\Prompt\Mime;
use Bellman\Prompt\Prompt;
$res = $llm->prompt(
Prompt::asUserWithData(Mime::APPLICATION_PDF, file_get_contents('report.pdf')),
'Summarize this report in three bullet points.',
);
$history = [Prompt::asUser('Pick a random Nordic capital.')];
$res = $llm->prompt(...$history);
$history = [...$history, ...$res->turn, Prompt::asUser('What is its population?')];
$res = $llm->prompt(...$history);
OpenAI::GenModel_gpt4o_mini();
VertexAI::EmbedModel_text_005();
OpenAI::genModels(); // all OpenAI generative models
Catalog::gen('OpenAI/gpt-4o'); // look up by "provider/name", null if unknown
use Bellman\Gen\Model;
new Model('VertexAI', 'gemini-2.5-flash', config: ['region' => 'us-central1']);
Model::fromFqn('OpenAI/some-new-model');