> ## 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-Vervollständigungen

> Rufe /chat/completions mit dem PHP SDK auf.

**Methoden**: `generateText()`, `createChatCompletion()`

### Beispiel

```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'];
```

### Wichtige Parameter

* `model` (erforderlich): ID des Zielmodells.
* `messages` (erforderlich): Nachrichten in Reihenfolge mit den Rollen `system|user|assistant|tool`; der Inhalt besteht aus MessageContent-Objekten.
* Stichprobenparameter: `temperature` (0–2), `top_p` (0–1), `top_k` (>=1), `seed` (int, optional).
* Länge und Strafwerte: `max_output_tokens` (int), `presence_penalty` und `frequency_penalty` (-2 bis 2), `stop` (string|string\[]).
* Tools: `tools` (Definitionen), `tool_choice` (automatisch/keins/bestimmtes Tool), `max_tool_calls` (int), `parallel_tool_calls` (bool).
* Logprobs: `logprobs` (bool), `top_logprobs` (0–20).
* Ausgabe: `response_format` (json/text), `meta` (bool zum Einfügen des meta-Blocks), `stream` (bool), `service_tier`.
* Zusätzliche Gateway-Optionen: `usage` (bool zum Anfordern der Nutzungsdaten).

### Rückgabe

ChatCompletionsResponse-JSON-Objekt.

```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.