> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/markup/wisej.ai.markupextensions.md).

# MarkupExtensions

Namespace: **Wisej.AI**

Assembly: **Wisej.AI** (3.5.0.0)

Provides extension methods for configuring and handling events on SmartEndpoint, SmartHttpEndpoint, SmartHub, and SmartSession objects.

{% tabs %}
{% tab title="C#" %}

```csharp
public class MarkupExtensions
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class MarkupExtensions
```

{% endtab %}
{% endtabs %}

The [MarkupExtensions](/ai/components/api/markup/wisej.ai.markupextensions.md) class offers a fluent API for setting properties and subscribing to events on various smart endpoint and session types. These extension methods enable concise and readable configuration of endpoints and event handlers.

## Methods

### ![](/files/6srAlWaUVvAWWpvmGKFp) ApiKey\<T>(endpoint, value)

Sets the API key for the specified HTTP endpoint.

| Parameter    | Type                                                          | Description                                                                                                        |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **T**        |                                                               | A type derived from [SmartHttpEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.smarthttpendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The HTTP endpoint to configure.                                                                                    |
| **value**    | [String](https://docs.microsoft.com/dotnet/api/system.string) | The API key.                                                                                                       |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured HTTP endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) Authentication\<T>(endpoint, value)

Sets the authentication string for the specified HTTP endpoint.

| Parameter    | Type                                                          | Description                                                                                                        |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **T**        |                                                               | A type derived from [SmartHttpEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.smarthttpendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The HTTP endpoint to configure.                                                                                    |
| **value**    | [String](https://docs.microsoft.com/dotnet/api/system.string) | The authentication string.                                                                                         |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured HTTP endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) ContextWindow\<T>(endpoint, value)

Sets the context window size for the specified endpoint.

| Parameter    | Type                                                        | Description                                                               |
| ------------ | ----------------------------------------------------------- | ------------------------------------------------------------------------- |
| **T**        |                                                             | A type derived from [SmartEndpoint](/ai/components/api/smartendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md) | The endpoint to configure.                                                |
| **value**    | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The context window size.                                                  |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) EmbeddingModel\<T>(endpoint, value)

Sets the embedding model for the specified endpoint.

| Parameter    | Type                                                          | Description                                                               |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------- |
| **T**        |                                                               | A type derived from [SmartEndpoint](/ai/components/api/smartendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The endpoint to configure.                                                |
| **value**    | [String](https://docs.microsoft.com/dotnet/api/system.string) | The embedding model name.                                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) Headers\<T>(endpoint, value)

Sets the HTTP headers for the specified HTTP endpoint.

| Parameter    | Type                                                                                                            | Description                                                                                                                               |
| ------------ | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **T**        |                                                                                                                 | A type derived from [SmartHttpEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.smarthttpendpoint.md).                        |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                                                     | The HTTP endpoint to configure.                                                                                                           |
| **value**    | [NameValueCollection](https://docs.microsoft.com/dotnet/api/system.collections.specialized.namevaluecollection) | A [NameValueCollection](https://docs.microsoft.com/dotnet/api/system.collections.specialized.namevaluecollection) containing the headers. |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured HTTP endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) MaxOutputTokens\<T>(endpoint, value)

Sets the maximum number of output tokens for the specified endpoint.

| Parameter    | Type                                                        | Description                                                               |
| ------------ | ----------------------------------------------------------- | ------------------------------------------------------------------------- |
| **T**        |                                                             | A type derived from [SmartEndpoint](/ai/components/api/smartendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md) | The endpoint to configure.                                                |
| **value**    | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The maximum number of output tokens.                                      |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) Model\<T>(endpoint, value)

Sets the model name for the specified endpoint.

| Parameter    | Type                                                          | Description                                                               |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------- |
| **T**        |                                                               | A type derived from [SmartEndpoint](/ai/components/api/smartendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The endpoint to configure.                                                |
| **value**    | [String](https://docs.microsoft.com/dotnet/api/system.string) | The model name to assign.                                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) Name\<T>(endpoint, value)

Sets the name for the specified endpoint.

| Parameter    | Type                                                          | Description                                                               |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------- |
| **T**        |                                                               | A type derived from [SmartEndpoint](/ai/components/api/smartendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The endpoint to configure.                                                |
| **value**    | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name to assign.                                                       |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnAfterInvokeTool\<T>(object, action)

Subscribes to the AfterInvokeTool event on the specified object.

| Parameter  | Type                                                                                  | Description                                                                    |
| ---------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                                                       | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                           | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action\<InvokeToolEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-1) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnAfterResponseReceived\<T>(object, action)

Subscribes to the AfterResponseReceived event on the specified object.

| Parameter  | Type                                                                                | Description                                                                    |
| ---------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                                                     | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                         | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action\<MessagesEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-1) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnBeforeInvokeTool\<T>(object, action)

Subscribes to the BeforeInvokeTool event on the specified object.

| Parameter  | Type                                                                                  | Description                                                                    |
| ---------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                                                       | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                           | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action\<InvokeToolEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-1) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnBeforeSendRequest\<T>(object, action)

Subscribes to the BeforeSendRequest event on the specified object.

| Parameter  | Type                                                                                | Description                                                                    |
| ---------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                                                     | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                         | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action\<MessagesEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-1) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnConvertParameter\<T>(object, action)

Subscribes to the ConvertParameter event on the specified object.

| Parameter  | Type                                                                                        | Description                                                                    |
| ---------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                                                             | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                                 | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action\<ConvertParameterEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-1) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnDone\<T>(object, action)

Subscribes to the Done event on the specified object.

| Parameter  | Type                                                          | Description                                                                    |
| ---------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                               | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action](https://docs.microsoft.com/dotnet/api/system.action) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnError\<T>(object, action)

Subscribes to the Error event on the specified object.

| Parameter  | Type                                                                             | Description                                                                    |
| ---------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                                                  | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                      | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action\<ErrorEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-1) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnPrepareMessages\<T>(object, action)

Subscribes to the PrepareMessage event on the specified object.

| Parameter  | Type                                                                                | Description                                                                    |
| ---------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                                                     | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)                         | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action\<MessagesEventArgs>](https://docs.microsoft.com/dotnet/api/system.action-1) | The action to invoke when the event is raised, receiving the event arguments.  |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) OnStart\<T>(object, action)

Subscribes to the Start event on the specified object.

| Parameter  | Type                                                          | Description                                                                    |
| ---------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| **T**      |                                                               | A type derived from [SmartObject](/ai/components/api/wisej.ai.smartobject.md). |
| **object** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The [SmartObject](/ai/components/api/wisej.ai.smartobject.md) to subscribe to. |
| **action** | [Action](https://docs.microsoft.com/dotnet/api/system.action) | The action to invoke when the event is raised.                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) RetryDelay\<T>(endpoint, value)

Sets the retry delay (in milliseconds) for the specified HTTP endpoint.

| Parameter    | Type                                                        | Description                                                                                                        |
| ------------ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **T**        |                                                             | A type derived from [SmartHttpEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.smarthttpendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md) | The HTTP endpoint to configure.                                                                                    |
| **value**    | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The retry delay in milliseconds.                                                                                   |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured HTTP endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) SystemPrompt\<T>(endpoint, value)

Sets the system prompt for the specified endpoint.

| Parameter    | Type                                                          | Description                                                               |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------- |
| **T**        |                                                               | A type derived from [SmartEndpoint](/ai/components/api/smartendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The endpoint to configure.                                                |
| **value**    | [String](https://docs.microsoft.com/dotnet/api/system.string) | The system prompt text.                                                   |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) Text\<T>(prompt, value)

Sets the Text for the specified SmartPrompt.

| Parameter  | Type                                                          | Description                                                           |
| ---------- | ------------------------------------------------------------- | --------------------------------------------------------------------- |
| **T**      |                                                               | A type derived from [SmartPrompt](/ai/components/api/smartprompt.md). |
| **prompt** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The SmartPrompt to configure.                                         |
| **value**  | [String](https://docs.microsoft.com/dotnet/api/system.string) | The text string.                                                      |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured SmartPrompt instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) URL\<T>(endpoint, value)

Sets the URL for the specified HTTP endpoint.

| Parameter    | Type                                                          | Description                                                                                                        |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **T**        |                                                               | A type derived from [SmartHttpEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.smarthttpendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)   | The HTTP endpoint to configure.                                                                                    |
| **value**    | [String](https://docs.microsoft.com/dotnet/api/system.string) | The URL to assign.                                                                                                 |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured HTTP endpoint instance.

### ![](/files/6srAlWaUVvAWWpvmGKFp) UseNativeTools\<T>(endpoint, value)

Specifies whether to use native tools for the specified endpoint.

| Parameter    | Type                                                            | Description                                                               |
| ------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------- |
| **T**        |                                                                 | A type derived from [SmartEndpoint](/ai/components/api/smartendpoint.md). |
| **endpoint** | [T](/ai/components/api/markup/wisej.ai.markupextensions.md)     | The endpoint to configure.                                                |
| **value**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | True to use native tools; otherwise, false.                               |

**Returns:** [T](/ai/components/api/markup/wisej.ai.markupextensions.md). The configured endpoint instance.


---

# 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.wisej.com/ai/components/api/markup/wisej.ai.markupextensions.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.
