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

# Generate an explanation for a query

> Generate a post-hoc explanation for a query. **Required scope:** write

Generate a post-hoc explanation for a query.

**Required scope:** `write`

### Request body

`ExplainRequest`

**query** `string` *required*

The query to explain

**session\_id** `string`

Session ID for context

**style** `string`

Explanation style: 'symbolic', 'neural', 'contrastive'

### Response

`ExplainResponse`

**components** `object`

**components**

**decision\_points** `string[]` *required*

Key decision points

**perception** `string` *required*

Perception explanation

**semantics** `string` *required*

Semantic computation explanation

**syntax** `string` *required*

Syntax (parsing) explanation

**enabled** `boolean` *required*

Whether explainability is enabled

**explanation** `string`

Human-readable explanation

### Status codes

| Code | Meaning |
| - | - |
| `200` | Explanation generated |
| `400` | Invalid request |
| `401` | Unauthorized — missing or invalid credentials |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |
| `500` | Failed to generate explanation |

```bash cURL theme={null}
curl --request POST \
  --url 'https://api.nsr.stateset.com/api/v1/explain' \
  --header "X-API-Key: $STATESET_NSR_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "string",
  "session_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "style": "string"
}'
```

```json 200 theme={null}
{
  "components": {
    "decision_points": [
      "string"
    ],
    "perception": "string",
    "semantics": "string",
    "syntax": "49.00"
  },
  "enabled": true,
  "explanation": "string"
}
```


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