📄 Source: test_curl.php
<?php
$url = 'http://127.0.0.1:11434/api/generate';
$data = ['model' => 'llama3.2:3b', 'prompt' => 'Say OK', 'stream' => false];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
$error = curl_error($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP: $code\n";
echo "Error: $error\n";
echo "Response: " . substr($response, 0, 200) . "\n";
?>
← Back