> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# إكمالات المحادثة

> استدعِ /chat/completions باستخدام PHP SDK.

**الأساليب**: `generateText()`, `createChatCompletion()`

### مثال

```php theme={null}
<?php

require 'vendor/autoload.php';

use Phaseo\Sdk\Phaseo;

$apiKey = getenv('PHASEO_API_KEY');
$client = new Phaseo(apiKey: $apiKey);

$response = $client->createChatCompletion([
    'model' => 'openai/gpt-4o-mini',
    'messages' => [[
        'role' => 'user',
        'content' => 'Write a limerick about lighthouses.',
    ]],
    'temperature' => 0.5
]);
echo $response['choices'][0]['message']['content'];
```

### المعاملات الأساسية

* `model` (مطلوب): معرّف النموذج المستهدف.
* `messages` (مطلوب): رسائل مرتبة بأدوار `system|user|assistant|tool`؛ ويكون المحتوى على هيئة كائنات MessageContent.
* أخذ العينات: `temperature` (من 0 إلى 2)، و`top_p` (من 0 إلى 1)، و`top_k` (>=1)، و`seed` (int، اختياري).
* الطول والعقوبات: `max_output_tokens` (int)، و`presence_penalty` و`frequency_penalty` (من -2 إلى 2)، و`stop` (string|string\[]).
* الأدوات: `tools` (تعريفات)، و`tool_choice` (تلقائي/بلا/أداة محددة)، و`max_tool_calls` (int)، و`parallel_tool_calls` (bool).
* Logprobs: `logprobs` (bool)، و`top_logprobs` (من 0 إلى 20).
* الإخراج: `response_format` (json/text)، و`meta` (bool لتضمين كتلة meta)، و`stream` (bool)، و`service_tier`.
* خيارات Gateway الإضافية: `usage` (bool لطلب بيانات الاستخدام).

### القيمة المعادة

كائن JSON من النوع ChatCompletionsResponse.

```json theme={null}
{
	"id": "chatcmpl-123",
	"object": "chat.completion",
	"created": 1677652288,
	"model": "gpt-3.5-turbo-0125",
	"choices": [
		{
			"index": 0,
			"message": {
				"role": "assistant",
				"content": "Hello there, how may I assist you today?"
			},
			"finish_reason": "stop"
		}
	],
	"usage": {
		"prompt_tokens": 9,
		"completion_tokens": 12,
		"total_tokens": 21
	}
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.