> ## 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.

# Handler for POST /api/v1/agents/llm/generate

> Direct access alias for the NS-RAG generation pipeline. **Required scope:** agents:admin

Direct access alias for the NS-RAG generation pipeline.

**Required scope:** `agents:admin`

### Request body

`RAGQueryRequest`

**include\_sources** `boolean`

**max\_context\_triples** `integer`

**model** `string`

**query** `string` *required*

**strategy** `string`

**verify** `boolean`

### Response

`RAGQueryResponse`

**answer** `string` *required*

**confidence** `number (float)` *required*

**context\_triples\_used** `integer` *required*

**hallucinations** `HallucinationReport[]` *required*

**HallucinationReport**

**claim** `string` *required*

**correction** `string`

**status** `HallucinationStatus` *required*

**sources** `SourceTriple[]` *required*

**SourceTriple**

**confidence** `number (float)` *required*

**object** `string` *required*

**predicate** `string` *required*

**subject** `string` *required*

**verified** `boolean` *required*

### Status codes

| Code | Meaning |
| - | - |
| `200` | Generated response |
| `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 |
| `503` | LLM backend unavailable |

```bash cURL theme={null}
curl --request POST \
  --url 'https://api.nsr.stateset.com/api/v1/agents/llm/generate' \
  --header "X-API-Key: $STATESET_NSR_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "include_sources": true,
  "max_context_triples": 1,
  "model": "string",
  "query": "string",
  "strategy": "string",
  "verify": true
}'
```

```json 200 theme={null}
{
  "answer": "string",
  "confidence": 7.5,
  "context_triples_used": 1,
  "hallucinations": [
    {
      "claim": "string",
      "correction": "string",
      "status": "Verified"
    }
  ],
  "sources": [
    {
      "confidence": 7.5,
      "object": "string",
      "predicate": "string",
      "subject": "Replacement tent pole set"
    }
  ],
  "verified": true
}
```


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