Integrations
openai-php/client is the most widely used OpenAI client for PHP. Point its base URI at DEVUP AI and the same code calls DEVUP AI models: chat, streaming, tool calling, JSON-schema output, and embeddings.
composer require openai-php/client guzzlehttp/guzzleopenai-php/client needs a PSR-18 HTTP client; Guzzle is the one used here. When Composer asks to trust php-http/discovery, allow it:
composer config allow-plugins.php-http/discovery trueexport DEVUP_API_KEY="your-key"The examples below are one PHP file. It starts with <?php, and each example continues from the previous one.
require __DIR__ . '/vendor/autoload.php';
$client = OpenAI::factory()
->withApiKey(getenv('DEVUP_API_KEY'))
->withBaseUri('https://api.devupai.com/v1')
->make();
$response = $client->chat()->create([
'model' => 'deepseek-ai/DeepSeek-V4-Pro',
'messages' => [
['role' => 'user', 'content' => 'Reply with exactly: Salam DEVUP'],
],
]);
echo $response->choices[0]->message->content, PHP_EOL;Output: Salam DEVUP
| Method | Value | Why |
|---|---|---|
| withApiKey | getenv('DEVUP_API_KEY') | Reads your DEVUP AI key from the environment. |
| withBaseUri | https://api.devupai.com/v1 | Sends every request to DEVUP AI. |
| make | — | Builds the client. |
createStreamed returns chunks as the model generates them.
$stream = $client->chat()->createStreamed([
'model' => 'deepseek-ai/DeepSeek-V4-Pro',
'messages' => [
['role' => 'user', 'content' => 'Count from 1 to 5, separated by spaces.'],
],
]);
foreach ($stream as $chunk) {
echo $chunk->choices[0]->delta->content ?? '';
}
echo PHP_EOL;Output: 1 2 3 4 5
The first request returns the tool the model wants to call. Run it, add the assistant message with toArray() and your result as a tool message, then send the conversation back.
$tools = [[
'type' => 'function',
'function' => [
'name' => 'get_order_status',
'description' => 'Look up the delivery status of an order by its ID.',
'parameters' => [
'type' => 'object',
'properties' => ['order_id' => ['type' => 'string']],
'required' => ['order_id'],
],
],
]];
$messages = [['role' => 'user', 'content' => 'What is the status of order A-100?']];
$first = $client->chat()->create([
'model' => 'deepseek-ai/DeepSeek-V4-Pro',
'messages' => $messages,
'tools' => $tools,
]);
$call = $first->choices[0]->message->toolCalls[0];
$args = json_decode($call->function->arguments, true);
$status = 'Order ' . $args['order_id'] . ' has shipped. Tracking number: DZ-4471.';
$messages[] = $first->choices[0]->message->toArray();
$messages[] = ['role' => 'tool', 'tool_call_id' => $call->id, 'content' => $status];
$final = $client->chat()->create([
'model' => 'deepseek-ai/DeepSeek-V4-Pro',
'messages' => $messages,
'tools' => $tools,
]);
echo $call->function->name, ': ', $final->choices[0]->message->content, PHP_EOL;The tracking number DZ-4471 only exists in your tool result, so seeing it in the final answer shows the round trip worked.
$response = $client->chat()->create([
'model' => 'deepseek-ai/DeepSeek-V4-Pro',
'messages' => [
['role' => 'user', 'content' => 'Which city is the capital of Algeria?'],
],
'response_format' => [
'type' => 'json_schema',
'json_schema' => [
'name' => 'capital',
'strict' => true,
'schema' => [
'type' => 'object',
'properties' => [
'city' => ['type' => 'string'],
'country' => ['type' => 'string'],
],
'required' => ['city', 'country'],
'additionalProperties' => false,
],
],
],
]);
$capital = json_decode($response->choices[0]->message->content, true);
echo $capital['city'], ', ', $capital['country'], PHP_EOL;Output: Algiers, Algeria
Prefer descriptive field names such as city over name. See Structured Outputs.
$embedding = $client->embeddings()->create([
'model' => 'BAAI/bge-m3',
'input' => 'Salam DEVUP',
]);
echo count($embedding->embeddings[0]->embedding), PHP_EOL;Output: 1024
BAAI/bge-m3 returns 1024-dimensional vectors. See Embeddings.
Use the exact catalog ID as model. Tool calling needs a model whose catalog entry supports it. See Models and Tool Calling.
PHP on Windows ships without CA certificates. Download cacert.pem from https://curl.se/ca/cacert.pem, then set both curl.cainfo and openssl.cafile to its full path in php.ini. Keep SSL verification on.
curl.cainfo = "C:\path\to\cacert.pem"
openssl.cafile = "C:\path\to\cacert.pem"Yes. Build the client with withBaseUri('https://api.devupai.com/v1') and your DEVUP AI key; chat, streaming, tools, JSON-schema output and embeddings then go to DEVUP AI.
openai-php/client requires PHP 8.2 or newer, with the openssl and curl extensions enabled.
Every request is a regular DEVUP AI API call, metered in Algerian Dinar on your account.
Download cacert.pem from curl.se and set curl.cainfo and openssl.cafile to its path in php.ini. Do not turn off SSL verification.
Yes. createStreamed returns chunks as the model generates them.
Yes. Call $client->embeddings()->create with a catalog embedding model such as BAAI/bge-m3, which returns 1024-dimensional vectors.