# Conversations

> Execute conversations, with or without streaming.

Source: https://docs.sommatic.ai/en/api/reference/conversations/

## Execute a conversation turn against a selected LLM provider.

`POST /chat/conversation/execute`

Executes a single conversation turn by persisting the inbound user message as an immutable ConversationRecord, invoking a concrete CognitiveInfrastructureLLMProvider (referenced by llm_provider_id), persisting the outbound assistant message as another immutable ConversationRecord, and returning the assistant output plus usage metadata.
This endpoint is the runtime entry point for multi-provider chat orchestration. Governance can be enforced through the ConversationManagement container (organization boundary, allowed providers, memory strategy, etc.).

Authentication: Bearer token

### Request body

Conversation execution request payload.


### Responses

- `200`: OK.
- `400`: Bad request (missing required fields or invalid identifiers).
- `403`: Forbidden (provider not allowed by conversation governance or cross-organization access).
- `500`: Something went wrong while performing this action.

### Example request

```bash
curl -X POST "https://api.sommatic.ai/chat/conversation/execute" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Execute a conversation turn against a selected LLM provider with SSE streaming.

`POST /chat/conversation/execute/stream`

Streaming variant of POST /chat/conversation/execute. Opens a persistent SSE connection and emits token chunks as they arrive from the LLM provider. The connection lifecycle:
1. event: open  — emitted immediately after context validation, before the first token. 2. event: chunk — emitted per token delta { text, index }. 3. event: done  — emitted once after full response is persisted; payload is identical
   to the JSON response returned by the synchronous /execute endpoint.
4. event: error — emitted on any failure; stream is then closed.
The existing POST /chat/conversation/execute endpoint is unchanged. Both endpoints share the same business logic and produce the same persisted output.

Authentication: Bearer token

### Request body

Conversation execution request payload (same shape as /execute).


### Responses

- `200`: SSE stream (text/event-stream).

### Example request

```bash
curl -X POST "https://api.sommatic.ai/chat/conversation/execute/stream" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}' \
  -N
```
