Integrations
The Laravel AI SDK (laravel/ai) is Laravel's official package for AI features. Its openai-compatible driver connects it to DEVUP AI, so agents, streaming, tools, structured output and embeddings run on DEVUP AI models.
composer require laravel/aiphp artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider"php artisan migratevendor:publish creates config/ai.php; the migration adds the tables the SDK uses to store agent conversations.
Add your key to .env:
DEVUP_API_KEY=your-keyThen add this entry under 'providers' in config/ai.php:
'devupai' => [
'driver' => 'openai-compatible',
'url' => 'https://api.devupai.com/v1',
'key' => env('DEVUP_API_KEY'),
'models' => [
'text' => ['default' => 'deepseek-ai/DeepSeek-V4-Pro'],
'embeddings' => ['default' => 'BAAI/bge-m3'],
],
],| Option | Value | Why |
|---|---|---|
| driver | openai-compatible | Uses the SDK's driver for OpenAI-compatible APIs. |
| url | https://api.devupai.com/v1 | Sends requests to DEVUP AI. Required. |
| key | env('DEVUP_API_KEY') | Sent as a bearer token. |
| models.text.default | deepseek-ai/DeepSeek-V4-Pro | The model agents use when you do not pass one. |
| models.embeddings.default | BAAI/bge-m3 | OpenAI-compatible providers need a default embeddings model. |
use function Laravel\Ai\agent;
$response = agent()->prompt('Reply with exactly: Salam DEVUP', provider: 'devupai');
echo $response->text, PHP_EOL;Output: Salam DEVUP
use Laravel\Ai\Streaming\Events\TextDelta;
foreach (agent()->stream('Count from 1 to 5, separated by spaces.', provider: 'devupai') as $event) {
if ($event instanceof TextDelta) {
echo $event->delta;
}
}
echo PHP_EOL;Output: 1 2 3 4 5
Return agent()->stream(...) from a route and Laravel sends it to the browser as server-sent events.
A tool implements the Tool contract: a description, a JSON schema for its arguments, and a handle method. php artisan make:tool generates one in app/Ai/Tools.
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Ai\Contracts\Tool;
use Laravel\Ai\Tools\Request;
class GetOrderStatus implements Tool
{
public function description(): string
{
return 'Look up the delivery status of an order by its ID.';
}
public function handle(Request $request): string
{
return 'Order ' . $request['order_id'] . ' has shipped. Tracking number: DZ-4471.';
}
public function schema(JsonSchema $schema): array
{
return [
'order_id' => $schema->string()->required(),
];
}
}
$answer = agent(tools: [new GetOrderStatus])->prompt('What is the status of order A-100?', provider: 'devupai');
echo $answer->text, PHP_EOL;The tracking number DZ-4471 only exists in the tool, so seeing it in the reply shows the tool ran.
$capital = agent(schema: fn (JsonSchema $schema) => [
'city' => $schema->string()->required(),
'country' => $schema->string()->required(),
])->prompt('Which city is the capital of Algeria?', provider: 'devupai');
echo $capital['city'], ', ', $capital['country'], PHP_EOL;Output: Algiers, Algeria
Prefer descriptive field names such as city over name. See Structured Outputs.
use Laravel\Ai\Embeddings;
$vectors = Embeddings::for(['Salam DEVUP'])->generate('devupai', 'BAAI/bge-m3');
echo count($vectors->embeddings[0]), PHP_EOL;Output: 1024
BAAI/bge-m3 returns 1024-dimensional vectors. See Embeddings.
Use exact catalog IDs in config/ai.php or pass model: to prompt. Tool calling needs a model whose catalog entry supports it. See Models and Tool Calling.
Yes. Add a provider with the openai-compatible driver, url https://api.devupai.com/v1 and your DEVUP AI key, then pass provider: 'devupai' when you prompt.
The Laravel AI SDK supports Laravel 12 and 13 and requires PHP 8.3 or newer.
Every request is a regular DEVUP AI API call, metered in Algerian Dinar on your account.
On a new Laravel 13 app it does not install: openai-php/laravel 0.21 requires Guzzle 7, and Laravel 13 installs Guzzle 8. The Laravel AI SDK has no such requirement.
OpenAI-compatible providers have no known models, so the Laravel AI SDK needs models.embeddings.default to create embeddings. BAAI/bge-m3 is a good default.
Yes. Return agent()->stream(...) from a route and Laravel sends it as server-sent events.