PHP Integration
You can easily integrate KoboiLLM into PHP projects using standard cURL or HTTP client libraries (such as Guzzle or Laravel’s Http facade).
Code Example (cURL)
<?php$ch = curl_init('https://api.koboillm.com/v1/chat/completions');
curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Authorization: Bearer sk-xxx...xxxx' // Enter your KoboiLLM API Key ], CURLOPT_POSTFIELDS => json_encode([ 'model' => 'openai/gpt-4o-mini', // Or anthropic/claude-3-5-sonnet, etc. 'messages' => [ ['role' => 'user', 'content' => 'this is a test request, write a short poem'] ] ])]);
$response = curl_exec($ch);curl_close($ch);
$data = json_decode($response, true);echo $data['choices'][0]['message']['content'];Required Configuration
| Parameter | Value |
|---|---|
| API Key | sk-xxxx (Virtual Key from Dashboard) |
| Base URL | https://api.koboillm.com/v1 |
| Model | Any active model ID (e.g., openai/gpt-4o-mini, anthropic/claude-3-5-sonnet) |
Best Practices
- Ensure the PHP
curlextension is enabled inphp.ini. - For Laravel applications, use
Http::withToken('sk-xxx')->post('https://api.koboillm.com/v1/chat/completions', [...]).