> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/local-ai/nvpair/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/local-ai/nvpair/_mcp/server.

# Ollama-compatible chat

POST http%3A%2F%2F127.0.0.1%3A11434/api/chat
Content-Type: application/json

Send an Ollama-compatible chat request to the local PAIR proxy. PAIR forwards the request to one eligible node running a compatible engine with the requested model available. With streaming enabled the upstream engine returns newline-delimited JSON chunks; the final chunk sets `done` to true.


Reference: https://docs.nvidia.com/local-ai/nvpair/pair-api/ollama-compatible/ollama-chat

## Request

### Body (application/json)

This endpoint expects an OllamaChatRequest.

- `model` (string, required) — Model name that must be available on an eligible node.
- `messages` (list of ChatMessage, required)
- `stream` (boolean, optional, default: true) — When true (the Ollama default), the response is streamed as newline-delimited JSON chunks.

## Response

### 200

Chat response from the serving node.

- `model` (string, required)
- `message` (ChatMessage, required)
- `done` (boolean, required)
- `created_at` (datetime, optional)
- `done_reason` (string, optional)
- `total_duration` (long, optional) — Total request time in nanoseconds, as reported by the engine.

## Types

### ChatMessage

- `role` (enum, required)
  - Allowed values: `system`, `user`, `assistant`, `tool`
- `content` (string, required)

## Examples

**Request**

```json
{
  "model": "llama3.1",
  "messages": [
    {
      "role": "user",
      "content": "Explain what NVIDIA Personal AI Router does in one sentence."
    }
  ],
  "stream": false
}
```

**Response**

```json
{
  "model": "llama3.1",
  "message": {
    "role": "assistant",
    "content": "NVIDIA Personal AI Router routes each AI request to one eligible system on your local network to serve inference."
  },
  "done": true,
  "created_at": "2026-06-03T07:45:00Z",
  "done_reason": "stop",
  "total_duration": 4200000000
}
```

**SDK Code**

```python default
import requests

url = "https://api.example.com/api/chat"

payload = {
    "model": "llama3.1",
    "messages": [
        {
            "role": "user",
            "content": "Explain what NVIDIA Personal AI Router does in one sentence."
        }
    ],
    "stream": False
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript default
const url = 'https://api.example.com/api/chat';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"model":"llama3.1","messages":[{"role":"user","content":"Explain what NVIDIA Personal AI Router does in one sentence."}],"stream":false}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go default
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/api/chat"

	payload := strings.NewReader("{\n  \"model\": \"llama3.1\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain what NVIDIA Personal AI Router does in one sentence.\"\n    }\n  ],\n  \"stream\": false\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby default
require 'uri'
require 'net/http'

url = URI("https://api.example.com/api/chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"llama3.1\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain what NVIDIA Personal AI Router does in one sentence.\"\n    }\n  ],\n  \"stream\": false\n}"

response = http.request(request)
puts response.read_body
```

```java default
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/api/chat")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"llama3.1\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain what NVIDIA Personal AI Router does in one sentence.\"\n    }\n  ],\n  \"stream\": false\n}")
  .asString();
```

```php default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/api/chat', [
  'body' => '{
  "model": "llama3.1",
  "messages": [
    {
      "role": "user",
      "content": "Explain what NVIDIA Personal AI Router does in one sentence."
    }
  ],
  "stream": false
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp default
using RestSharp;

var client = new RestClient("https://api.example.com/api/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"llama3.1\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain what NVIDIA Personal AI Router does in one sentence.\"\n    }\n  ],\n  \"stream\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift default
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "model": "llama3.1",
  "messages": [
    [
      "role": "user",
      "content": "Explain what NVIDIA Personal AI Router does in one sentence."
    ]
  ],
  "stream": false
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/chat")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```