📄 Source: test_ollama.php
<?php
$ch = curl_init('http://localhost:11434/api/generate');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'model' => 'llama3.2:3b',
'prompt' => 'Say OK',
'stream' => false
]));
$response = curl_exec($ch);
$error = curl_error($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Code: $code\n";
echo "CURL Error: $error\n";
echo "Response: " . substr($response, 0, 200) . "\n";
?>
← Back