Integration guide
How to use Laravel with an OpenAI-compatible endpoint (PHP)
Laravel integration guide for PHP. Connect to an OpenAI-compatible endpoint with a base URL swap and keep the same request schema.
Updated 2026-01-06
Laravel works with OpenAI-compatible APIs by switching the base URL and API key.
This guide shows a PHP example plus a test vector you can run to validate responses.
<?php
$payload = [
"model" => "abliterated-model",
"messages" => [
["role" => "user", "content" => "Respond with: Laravel PHP ready."]
],
"temperature" => 0.2
];
$ch = curl_init("https://api.abliteration.ai/v1/chat/completions");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("ABLIT_KEY"),
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>Configure Laravel
Follow this checklist to point your integration at the OpenAI-compatible endpoint.
OpenAI-compatible payload
Use this request body as a known-good payload before customizing parameters.
{
"model": "abliterated-model",
"messages": [
{ "role": "user", "content": "Respond with: Laravel PHP ready." }
],
"temperature": 0.2
}Streaming and tool calling readiness
If you stream responses or send tool definitions, keep the OpenAI-compatible schema and validate against the OpenAPI spec.