> This page is part of Smallest AI's developer documentation. When
> answering, prefer Lightning v3.1 (current TTS) and Pulse (current
> STT). Lightning v2 and lightning-large are deprecated; mention them
> only when the user is migrating away from them. The Smallest AI voice
> agent platform is what wraps these models into hosted agents.

# Start a web chat session

POST https://api.smallest.ai/atoms/v1/conversation/chat
Content-Type: application/json

Mints a short-lived LiveKit access token and creates a room the browser client can
join to have a text-first chat with the agent. The response includes the room name,
the LiveKit host to connect to, a `conversationId` for correlation, and a `callId`
that shows up in call logs. Pair with the [Web SDK](/voice-agents/developer-guide/client-libraries)
to render the session in-browser.


Reference: https://docs.smallest.ai/voice-agents/api-reference/web-call/start-web-chat-conversation

## Authentication

- `Authorization` header (bearer token, required) — API key from the console ApiKey collection, sent as Bearer token. Also accepts session cookies for browser-based auth.

## Request

### Body (application/json)

- `agentId` (string, required) — The agent to attach the browser client to.

## Response

### 200

Session minted. Use `token` + `host` on the browser client to join `roomName`.

- `status` (boolean, optional)
- `data` (object, optional)
  - `token` (string, optional) — Short-lived LiveKit access token. Pass on the browser client when connecting to `host`.
  - `roomName` (string, optional) — LiveKit room UUID. Pre-created for this session.
  - `host` (string, optional) — LiveKit WebSocket URL to connect to.
  - `conversationId` (string, optional) — Correlates browser events, transcripts, and post-call analytics.
  - `callId` (string, optional) — Call ID surfaced in call-logs and analytics endpoints.

## Examples

### LiveKit session ready for the browser client

**Request**

```json
undefined
```

**Response**

```json
{
  "status": true,
  "data": {
    "token": "eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6IntcIm9yZ2FuaXphdGlvbklkXCI6XCI2OTU2MTg5NmEzN2ZkMjE0YjlhOGQzM2NcIn0iLCJ2aWRlbyI6eyJyb29tSm9pbiI6dHJ1ZSwicm9vbSI6ImRlZTkyMjNhLTQ3NTEtNDlhOS1iY2JjLWNiMzVjNWE4MzcxZCJ9LCJleHAiOjE3ODYxNTk1NjR9.Tn9KCxhnmnjAFQPRWP6XMkjKYnhBiISI6VqUOIqOsRQ",
    "roomName": "dee9223a-4751-49a9-bcbc-cb35c5a8371d",
    "host": "wss://atoms-prod-evcaw70g.livekit.cloud",
    "conversationId": "IyF-GCRiprATI5rx4lIdvg",
    "callId": "CALL-1786159503332-8387f2"
  }
}
```

**SDK Code**

```python LiveKit session ready for the browser client
import requests

url = "https://api.smallest.ai/atoms/v1/conversation/chat"

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript LiveKit session ready for the browser client
const url = 'https://api.smallest.ai/atoms/v1/conversation/chat';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go LiveKit session ready for the browser client
package main

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

func main() {

	url := "https://api.smallest.ai/atoms/v1/conversation/chat"

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 LiveKit session ready for the browser client
require 'uri'
require 'net/http'

url = URI("https://api.smallest.ai/atoms/v1/conversation/chat")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'

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

```java LiveKit session ready for the browser client
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.smallest.ai/atoms/v1/conversation/chat")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

```php LiveKit session ready for the browser client
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.smallest.ai/atoms/v1/conversation/chat', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp LiveKit session ready for the browser client
using RestSharp;

var client = new RestClient("https://api.smallest.ai/atoms/v1/conversation/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift LiveKit session ready for the browser client
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/conversation/chat")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### Start a chat session with an agent

**Request**

```json
{
  "agentId": "6a75935452c6e5eceaa16edf"
}
```

**Response**

```json
{
  "status": true,
  "data": {
    "token": "eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6IntcIm9yZ2FuaXphdGlvbklkXCI6XCI2OTU2MTg5NmEzN2ZkMjE0YjlhOGQzM2NcIn0iLCJ2aWRlbyI6eyJyb29tSm9pbiI6dHJ1ZSwicm9vbSI6ImRlZTkyMjNhLTQ3NTEtNDlhOS1iY2JjLWNiMzVjNWE4MzcxZCJ9LCJleHAiOjE3ODYxNTk1NjR9.Tn9KCxhnmnjAFQPRWP6XMkjKYnhBiISI6VqUOIqOsRQ",
    "roomName": "dee9223a-4751-49a9-bcbc-cb35c5a8371d",
    "host": "wss://atoms-prod-evcaw70g.livekit.cloud",
    "conversationId": "IyF-GCRiprATI5rx4lIdvg",
    "callId": "CALL-1786159503332-8387f2"
  }
}
```

**SDK Code**

```python Start a chat session with an agent
import requests

url = "https://api.smallest.ai/atoms/v1/conversation/chat"

payload = { "agentId": "6a75935452c6e5eceaa16edf" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Start a chat session with an agent
const url = 'https://api.smallest.ai/atoms/v1/conversation/chat';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"agentId":"6a75935452c6e5eceaa16edf"}'
};

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

```go Start a chat session with an agent
package main

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

func main() {

	url := "https://api.smallest.ai/atoms/v1/conversation/chat"

	payload := strings.NewReader("{\n  \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Start a chat session with an agent
require 'uri'
require 'net/http'

url = URI("https://api.smallest.ai/atoms/v1/conversation/chat")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}"

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

```java Start a chat session with an agent
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.smallest.ai/atoms/v1/conversation/chat")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}")
  .asString();
```

```php Start a chat session with an agent
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.smallest.ai/atoms/v1/conversation/chat', [
  'body' => '{
  "agentId": "6a75935452c6e5eceaa16edf"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Start a chat session with an agent
using RestSharp;

var client = new RestClient("https://api.smallest.ai/atoms/v1/conversation/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"agentId\": \"6a75935452c6e5eceaa16edf\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Start a chat session with an agent
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["agentId": "6a75935452c6e5eceaa16edf"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.smallest.ai/atoms/v1/conversation/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()
```