> 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/smartendpoint/wisej.ai.endpoints.ollamaendpoint.md).

# OllamaEndpoint

Namespace: **Wisej.AI.Endpoints**

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

* [SmartEndpoint](/ai/components/api/smartendpoint.md)
  * [SmartHttpEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.smarthttpendpoint.md)
    * [OllamaEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.ollamaendpoint.md)

Represents an endpoint that connects to Ollama services, providing functionalities for chat and embeddings.

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

```csharp
public class OllamaEndpoint : SmartHttpEndpoint
```

{% endtab %}

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

```visual-basic
Public Class OllamaEndpoint
    Inherits SmartHttpEndpoint
```

{% endtab %}
{% endtabs %}

This class extends the [SmartHttpEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.smarthttpendpoint.md) to interact with Ollama endpoints. It provides methods to construct API URLs, add options to messages, and handle responses.

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) OllamaEndpoint()

Initializes a new instance of the [OllamaEndpoint](/ai/components/api/smartendpoint/wisej.ai.endpoints.ollamaendpoint.md) class with default settings.

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) EmbeddingModel

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the embedding model used by the endpoint. (Default: `"all-minilm"`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) MaxContextTokens

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the maximum number of tokens the context window for the specified [Model](/ai/components/api/smartendpoint.md#model) can hold. (Default: `8192`)

## Methods

### ![](/files/KL0Ik37djZRr8a07Wopd) AddOptions(message, session)

Adds options to the message for the current session.

| Parameter   | Type                                                          | Description                                            |
| ----------- | ------------------------------------------------------------- | ------------------------------------------------------ |
| **message** | [Object](https://docs.microsoft.com/dotnet/api/system.object) | The dynamic message object to which options are added. |
| **session** | [SmartSession](/ai/components/api/smartsession.md)            | The current session containing model options.          |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the message is null.

### ![](/files/ptrKjmmRoQB76pvrIqh0) AskEmbeddingsAsync(inputs)

Asynchronously requests embeddings for the specified inputs.

| Parameter  | Type                                                              | Description                                                   |
| ---------- | ----------------------------------------------------------------- | ------------------------------------------------------------- |
| **inputs** | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | An array of input strings for which embeddings are requested. |

**Returns:** [Task\<Embedding>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation, with a result of type [Embedding](/ai/components/api/embeddings/wisej.ai.embeddings.embedding.md).

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the inputs are null.

### ![](/files/KL0Ik37djZRr8a07Wopd) BuildEmbeddingsPayload(inputs)

Builds the payload for the embeddings request.

| Parameter  | Type                                                              | Description                                               |
| ---------- | ----------------------------------------------------------------- | --------------------------------------------------------- |
| **inputs** | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | An array of input strings for which the payload is built. |

**Returns:** [Object](https://docs.microsoft.com/dotnet/api/system.object). An object representing the payload for the embeddings request.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the inputs are null.

### ![](/files/KL0Ik37djZRr8a07Wopd) GetApiURL()

Constructs the API URL for chat interactions.

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string). A string representing the chat API URL.

### ![](/files/KL0Ik37djZRr8a07Wopd) GetEmbeddingsURL()

Constructs the API URL for embeddings interactions.

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string). A string representing the embeddings API URL.

### ![](/files/KL0Ik37djZRr8a07Wopd) ReadAssistantMessage(response, message)

Reads the assistant's message from the response and updates the message object.

| Parameter    | Type                                                                            | Description                                                     |
| ------------ | ------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| **response** | [Response](/ai/components/api/smartendpoint/wisej.ai.smartendpoint.response.md) | The response received from the API.                             |
| **message**  | [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md)     | The message object to be updated with the assistant's response. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the response or message is null.

### ![](/files/KL0Ik37djZRr8a07Wopd) ReadEmbeddingsResponse(response)

Reads the embeddings response and extracts the embeddings data.

| Parameter    | Type                                                                            | Description                         |
| ------------ | ------------------------------------------------------------------------------- | ----------------------------------- |
| **response** | [Response](/ai/components/api/smartendpoint/wisej.ai.smartendpoint.response.md) | The response received from the API. |

**Returns:** [Single\[\]\[\]](https://docs.microsoft.com/dotnet/api/system.single). A jagged array of floats representing the embeddings.

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when the response is null.

### ![](/files/KL0Ik37djZRr8a07Wopd) ReadUsage(message, reply)

Reads the usage statistics from the reply and updates the message usage.

| Parameter   | Type                                                                        | Description                                             |
| ----------- | --------------------------------------------------------------------------- | ------------------------------------------------------- |
| **message** | [Message](/ai/components/api/smartsession/wisej.ai.smartsession.message.md) | The message object to be updated with usage statistics. |
| **reply**   | [Object](https://docs.microsoft.com/dotnet/api/system.object)               | The dynamic reply object containing usage information.  |


---

# 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:

```
GET https://docs.wisej.com/ai/components/api/smartendpoint/wisej.ai.endpoints.ollamaendpoint.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
