> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/ai-in-umbraco/17.latest/using-the-api/chat/advanced-options.md).

# Advanced Options

Override profile defaults on a per-request basis using `ChatOptions`. These options are passed directly to the AI provider.

## ChatOptions

Pass `ChatOptions` through the builder to configure chat behavior:

{% code title="WithOptions.cs" %}

```csharp
var messages = new List<ChatMessage>
{
    new(ChatRole.User, "Write three tagline options for a coffee shop.")
};

var options = new ChatOptions
{
    Temperature = 0.9f,
    MaxOutputTokens = 200,
    TopP = 0.95f,
    StopSequences = ["---"]
};

var response = await _chatService.GetChatResponseAsync(
    chat => chat.WithAlias("tagline-writer").WithChatOptions(options),
    messages);
```

{% endcode %}

## Available Options

| Option             | Type                  | Description                                           |
| ------------------ | --------------------- | ----------------------------------------------------- |
| `Temperature`      | `float?`              | Controls randomness (0 = deterministic, 1 = creative) |
| `MaxOutputTokens`  | `int?`                | Maximum tokens in the response                        |
| `TopP`             | `float?`              | Nucleus sampling threshold                            |
| `StopSequences`    | `IList<string>?`      | Sequences that stop generation                        |
| `FrequencyPenalty` | `float?`              | Penalizes repeated tokens                             |
| `PresencePenalty`  | `float?`              | Penalizes tokens already present                      |
| `Seed`             | `long?`               | Seed for reproducible outputs                         |
| `ResponseFormat`   | `ChatResponseFormat?` | Request JSON or text output                           |

{% hint style="info" %}
Not all providers support every option. Unsupported options are ignored. Check the provider documentation for supported parameters.
{% endhint %}

## Requesting JSON Output

Use `ChatResponseFormat` to request structured JSON responses:

{% code title="JsonResponse.cs" %}

```csharp
var options = new ChatOptions
{
    ResponseFormat = ChatResponseFormat.Json
};

var messages = new List<ChatMessage>
{
    new(ChatRole.System, "Return a JSON object with 'title' and 'summary' fields."),
    new(ChatRole.User, "Describe Umbraco CMS.")
};

var response = await _chatService.GetChatResponseAsync(
    chat => chat.WithAlias("json-responder").WithChatOptions(options),
    messages);
// response.Message.Text contains JSON: {"title": "...", "summary": "..."}
```

{% endcode %}

## Combining with Profiles

Options override profile settings for that request only. The profile settings remain unchanged:

{% code title="Override.cs" %}

```csharp
// Profile has Temperature = 0.7
var options = new ChatOptions
{
    Temperature = 0.2f  // Override to more deterministic for this request
};

var response = await _chatService.GetChatResponseAsync(
    chat => chat.WithAlias("profile-example").WithProfile(profileId).WithChatOptions(options),
    messages);
```

{% endcode %}

## Related

* [Basic Chat](/ai-in-umbraco/17.latest/using-the-api/chat/basic-chat.md) - Sending chat requests
* [Streaming](/ai-in-umbraco/17.latest/using-the-api/chat/streaming.md) - Streaming with options
* [Profiles](/ai-in-umbraco/17.latest/concepts/profiles.md) - Default profile settings


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.umbraco.com/ai-in-umbraco/17.latest/using-the-api/chat/advanced-options.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
