# Chat API

**POST** `https://api.oneover.com/functions/v1/api-v1-chat`

**Scope:** `chat`

Stateless chat completions across every text model. Streaming and non-streaming. Prompts are not retained after the response.

## Request body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| model | string | yes | Text model ID from your catalog |
| messages | array | yes | `{ role, content }` turns |
| stream | boolean | no | If true, returns SSE instead of JSON |
| max_tokens | number | no | Optional completion budget cap |

## Response (non-streaming)

```json
{
  "request_id": "uuid",
  "model": "gpt-5.6-sol",
  "message": { "role": "assistant", "content": "..." },
  "credits_charged": 4,
  "balance": { "subscription": 14996, "anytime": 5000 },
  "efficiency": {
    "original_estimated_tokens": 4200,
    "compacted_estimated_tokens": 2800,
    "tokens_saved": 1400,
    "actions": ["dropped_2_old_turns"]
  }
}
```

## Streaming events

| Event | Description |
|-------|-------------|
| connection_established | Handshake with request_id |
| content | Token chunk in content field |
| done | Final event with credits_charged, balance, efficiency |
| error | Failure during stream |
