> ## Documentation Index
> Fetch the complete documentation index at: https://krastieai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat sessions

> Manage AI assistant sessions with visibility-aware workspace context.

Base path: `/v1/ai/chat`

Use `POST /v1/ai/generate/chat` to send messages with access to your visibility data, traffic metrics, and documents. Use these routes to manage session history.

| Method | Endpoint | Description |
| - | - | - |
| `GET` | `/sessions` | List chat sessions |
| `GET` | `/session` | Get session (query params) |
| `POST` | `/session` | Create session. Body: `{ "sessionId": "optional-id" }` |
| `GET` | `/session/:sessionId` | Get session by ID |
| `DELETE` | `/session/:sessionId` | Delete session |
| `POST` | `/brand-voice` | Generate brand voice |
| `GET` | `/getFineTuningJob` | Fine-tuning job status |
| `POST` | `/feedback` | Session feedback |
| `PUT` | `/brandVoices/:id` | Update brand voice |
| `DELETE` | `/brandVoices/:id` | Delete brand voice |

## Workspace context

Set `useWorkspaceContext: true` (the default) when calling `POST /v1/ai/generate/chat` to include visibility scores, report recommendations, and workspace documents in the assistant's context.

Check available context first with `GET /v1/ai/generate/assistant/context`.

## Create a session

```bash theme={null}
curl -X POST https://api.krastie.ai/v1/ai/chat/session \
  -H "Content-Type: application/json" \
  -H "api-key: krastie_YOUR_KEY" \
  -d '{"sessionId": "visibility-review-1"}'
```

**Response (201):**

```json theme={null}
{
  "message": "Chat session created successfully.",
  "sessionId": "visibility-review-1",
  "session": {}
}
```

## List sessions

```bash theme={null}
curl https://api.krastie.ai/v1/ai/chat/sessions \
  -H "api-key: krastie_YOUR_KEY"
```

## Ask about visibility

Pass the `sessionId` from an existing or newly created session to `POST /v1/ai/generate/chat`:

```bash theme={null}
curl -X POST https://api.krastie.ai/v1/ai/generate/chat \
  -H "Content-Type: application/json" \
  -H "api-key: krastie_YOUR_KEY" \
  -d '{
    "text": "What are my top AI visibility gaps and which prompts should I target first?",
    "model": "gpt-4o",
    "sessionId": "visibility-review-1",
    "useWorkspaceContext": true
  }'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.