# Chat and sessions

> Nexus UI's home is a chat. Ask any model your organization allows, in sessions that are private to you.

Nexus UI opens on a chat. Write a question, pick a model, and the answer streams in. Each conversation is a
**session**: it keeps its messages, the model that ran, the team its spend goes to and what it cost. The same sessions
are in the CLI (`nexus chat`) and the API (`/v1/chat/sessions`).

## Asking

Chat answers with any model your organization allows. `nexus/auto` is the default: Nexus chooses within your
model policy, and every answer says which model ran. Web search is off by default. When an owner or admin turns it
on under Settings › Policy, the model may search the web, and the answer lists its web sources.

## Models, policies and cost

Every message takes the same path as any other model call through Nexus: your
[model policy](/docs/concepts/models-and-policies) decides first (a block always wins), the call's maximum cost is
reserved against the budget, and the [ledger](/docs/concepts/ledger) settles what it really cost. The spend is
[attributed](/docs/concepts/attribution) to you, your team and the product `chat`, so it shows in Usage like
the rest.

The model picker lists the models you may use, with coming-soon models muted; blocked models are not listed. If a
policy refuses a model, for example after an owner changes it, the refusal is kept in the session with its reason,
and nothing is sent or charged. Choose another model and continue.

## Privacy and retention

- **Sessions are private to the person who starts them.** Nobody else can read them, owners and admins included,
  unless you share one: see [Artifacts: share chats and pages](/docs/guides/artifacts).
  Owners and admins see counts only (sessions, messages, people and cost), through
  [`GET /v1/analytics/chat`](/docs/api/analytics#get-chat-usage).
- **Message content never enters the audit log.** The [audit log](/docs/concepts/audit-log) records that a session
  was created or deleted, never its title or messages.
- **Messages are kept for 90 days by default.** Owners and admins choose from 1 to 3650 days for the organization, under
  Settings › Data or with [`PUT /v1/orgs/settings`](/docs/api/organizations#set-org-settings); the change is audited.
  Older messages, and sessions with no activity in that window, are deleted. A shorter window applies at once.

## In Nexus UI

The sidebar starts with **New session** and your recent sessions, with a search. A session's page shows its messages,
the model, the team and the running cost, and lets you rename, archive or delete it. Enter sends; Shift+Enter starts
a new line. **Get started**, under the composer on the home page, tracks the first steps for your organization:
link your subscriptions or a provider key, connect GitHub, install the CLI, invite a teammate and try a first prompt.

## From the CLI

```sh
nexus chat "How should we structure our onboarding docs?"   # continues the session you used last
nexus chat "Where is billing handled?" --new                  # a new session
nexus chat "Shorter, please" --model anthropic/claude-haiku-5-5
nexus chat sessions                                           # your sessions
nexus chat sessions show <id>
nexus chat sessions rename <id> "Onboarding docs"
nexus chat sessions archive <id>                              # --undo brings it back
nexus chat sessions delete <id>
```

The answer streams as it is written. `--team <slug>` attributes the session to a team you are in, `--session <id>`
picks a session, and `--json` prints the stored question and answer. See the [CLI reference](/docs/cli).

## Through the API

```sh
# Start a session (model: nexus/auto unless you name one)
curl -X POST "$NEXUS_URL/v1/chat/sessions" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

# Send a message: the answer streams as server-sent events
curl -N -X POST "$NEXUS_URL/v1/chat/sessions/<id>/messages" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"content": "Where is billing handled?"}'
```

The stream uses OpenAI's `chat.completion.chunk` events. The first carries the session and the stored question, the
next ones carry the text, and the last carries `usage`, the cost and the stored answer. `data: [DONE]` ends it.
Send `"stream": false` to get the question and answer as JSON once the answer is done.

A refusal is answered before any stream starts, with Gateway's error (`403 model_not_allowed`, naming the policy level
and rule, or `402 budget_exceeded`); `error.nexus` names the session and the stored message. With an
[`Idempotency-Key`](/docs/concepts/idempotency), a message that settled is not run or charged again. The full reference:
[Chat sessions](/docs/api/chat).
