> ## 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/).
</Note>

## Basic Parameters

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

## Advanced Parameters

<div className="integrations-table">
  | 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. |
</div>

## 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
	}
}
```

## Workflow Library Example

[Generate Chat Completion with Helix and Send Results Via Email](https://library.blinkops.com/workflows/generate-chat-completion-with-helix-and-send-results-via-email)

<div className="iframe-wrapper">
  <div className="iframe-media">
    <img src="https://mintcdn.com/blinkops-2/ojHYuDeYX5FWuN8a/img/Icons/play-box.svg?fit=max&auto=format&n=ojHYuDeYX5FWuN8a&q=85&s=b8af968e71438a9499c3223c9bd29fb2" alt="Workflow Library" width="16" height="16" data-path="img/Icons/play-box.svg" />

    Preview this Workflow on desktop
  </div>

  <iframe className="iframe" src="https://library.blinkops.com/workflows/generate-chat-completion-with-helix-and-send-results-via-email/canvas" />
</div>
