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

# Generate Chat Completion

Generate a chat completion response from a model using a conversation history.

**Note**: To chat with a specific agent instead of a bare model, connect using an agent-specific API key. The agent's configuration, including its system prompt, knowledge, and tools, is automatically applied. For more information, visit [Helix documentation](https://docs.helixml.tech/helix/api-reference/sessions/chat-session/#using-with-agents).

> [!NOTE]
>
> External Documentation
>
> To learn more, visit the [Helix documentation](https://docs.helixml.tech/helix/api-reference/sessions/chat-session/).

## Basic Parameters

| Parameter | Description |
| - | - |
| Messages | The list of messages in the conversation. Each message is an object with a `role` (`system`, `user`, or `assistant`) and a `content` string. Example: <pre>`[  {"role": "system", "content": "You are a helpful assistant."},  {"role": "user", "content": "What is the capital of France?"}]`</pre> |
| Model | The model used to generate the chat completion, for example `qwen3:8b`. |

## Advanced Parameters

| Parameter | Description |
| - | - |
| Max Tokens | The maximum number of tokens to generate in the chat completion. |
| Temperature | The sampling temperature to use. Values can range from `0` to `2`. |
| Top P | The nucleus sampling parameter, where the model considers the tokens with `top_p` probability mass. |

## Example Output

```json theme={"dark"}
{
	"id": "ses_01a4t10c132825d3k037tyh7ap",
	"object": "chat.completion",
	"created": 1723155364,
	"model": "qwen3:8b",
	"choices": [
		{
			"index": 0,
			"finish_reason": "stop",
			"message": {
				"role": "assistant",
				"content": "The capital of France is Paris."
			}
		}
	],
	"usage": {
		"prompt_tokens": 24,
		"completion_tokens": 8,
		"total_tokens": 32
	}
}
```
