---
title: "Conversații | Documentație | Private AI Workspace by R&D Copilot"
description: "Citește resursele din conversații și câmpurile cererilor și răspunsurilor."
canonical: "https://private-ai.rdcopilot.com/ro/docs/api-reference/chat/"
language: ro
updated: 2026-11-22
---

# Conversații

Citește resursele din conversații și câmpurile cererilor și răspunsurilor.

## Trimite o întrebare

POST `/private-ai/v1/chat`

Creează conversația cu expectedRevision 0. Identitatea și permisiunile provin din autentificare. Întrebarea primește răspuns din fișierele indexate pe care apelantul le poate citi, de la un model încărcat pe care echipa lui îl poate folosi; nimic nu iese din instalare. Trimite Prefer: wait=10 ca să primești conversația încheiată în răspunsul 202, dacă e gata la timp; altfel citește operația, apoi aggregateId. O întrebare la care nu răspunde niciun fișier accesibil rămâne o conversație încheiată fără răspuns și fără citare. O acțiune nouă cere un operationId nou.

### Parametri

| Nume | În | Tip | Obligatoriu | Descriere |
| --- | --- | --- | --- | --- |
| `Prefer` | header | `string` | Nuopțional | wait=<secunde>, cel mult 30: răspunsul conține conversația încheiată dacă este gata la timp. Fără el, citește operația. |

### Corpul cererii

| Câmp | Tip | Obligatoriu | Descriere |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Daobligatoriu | Un UUID nou pentru o acțiune nouă; refolosește-l după expirarea cererii. |
| `expectedRevision` | `integer` | Daobligatoriu | Revizia pe care ai citit-o ultima dată. |
| `spaceId` | `string` | Daobligatoriu | Identificator stabil al înregistrării. |
| `modelId` | `string` | Daobligatoriu | Identificator stabil al înregistrării. |
| `question` | `string` | Daobligatoriu | Întrebare. |

### Răspunsuri

| Stare | Descriere | Corp |
| --- | --- | --- |
| `202` | Operația a fost acceptată. Cu Prefer: wait și un răspuns gata la timp, rezultatul conține conversația încheiată. | `ChatOperationResult` |
| `400` | invalid\_request | `Error` |
| `401` | unauthorized | `Error` |
| `403` | forbidden | `Error` |
| `404` | record\_not\_found | `Error` |
| `409` | revision\_conflict | `Error` |
| `422` | invalid\_transition | `Error` |
| `429` | rate\_limited | `Error` |
| `503` | unavailable | `Error` |

### Cerere

curl

```bash
curl -X POST "$RDC_BASE_URL/private-ai/v1/chat" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "expectedRevision": 0,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/private-ai/v1/chat`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "8a000001-0000-4000-8000-000000000001",
    "expectedRevision": 0,
    "spaceId": "warehouse",
    "modelId": "model-primary",
    "question": "What do we do with damaged goods at receiving?"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/private-ai/v1/chat',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '8a000001-0000-4000-8000-000000000001',
        'expectedRevision': 0,
        'spaceId': 'warehouse',
        'modelId': 'model-primary',
        'question': 'What do we do with damaged goods at receiving?',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "expectedRevision": 0,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/private-ai/v1/chat');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/private-ai/v1/chat");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "expectedRevision": 0,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Răspuns `202`

JSON

```json
{
  "operationId": "8a000001-0000-4000-8000-000000000001",
  "status": "completed",
  "aggregateId": "8a000002-0000-4000-8000-000000000001",
  "aggregateRevision": 1,
  "chat": {
    "id": "8a000002-0000-4000-8000-000000000001",
    "revision": 1,
    "spaceId": "warehouse",
    "modelId": "model-primary",
    "question": "What do we do with damaged goods at receiving?",
    "status": "answered",
    "path": [
      "received",
      "authorized",
      "retrieved",
      "drafted",
      "answered"
    ],
    "answer": "Photograph the damaged goods, move them to the quarantine bay and report them to the supplier within one working day.",
    "citations": [
      {
        "documentId": "doc-procedure",
        "title": "Receiving procedure",
        "locator": "Section 4, Damaged goods",
        "passage": "Damaged goods are photographed, moved to the quarantine bay and reported to the supplier within one working day."
      }
    ],
    "documentIds": [
      "doc-procedure"
    ],
    "code": null
  }
}
```

## Citește răspunsul sau refuzul

GET `/private-ai/v1/chat/{chatId}`

### Parametri

| Nume | În | Tip | Obligatoriu | Descriere |
| --- | --- | --- | --- | --- |
| `chatId` | path | `string` | Daobligatoriu | Identificatorul înregistrării. |

### Răspunsuri

| Stare | Descriere | Corp |
| --- | --- | --- |
| `200` | Starea curentă a înregistrării. | `Chat` |
| `401` | unauthorized | `Error` |
| `403` | forbidden | `Error` |
| `404` | Înregistrarea nu există în această instalare. | `Error` |
| `429` | rate\_limited | `Error` |
| `503` | unavailable | `Error` |

### Cerere

curl

```bash
curl "$RDC_BASE_URL/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/private-ai/v1/chat/8a000002-0000-4000-8000-000000000001");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Răspuns `200`

JSON

```json
{
  "id": "8a000002-0000-4000-8000-000000000001",
  "revision": 1,
  "spaceId": "warehouse",
  "modelId": "model-primary",
  "question": "What do we do with damaged goods at receiving?",
  "status": "answered",
  "path": [
    "received",
    "authorized",
    "retrieved",
    "drafted",
    "answered"
  ],
  "answer": "Photograph the damaged goods, move them to the quarantine bay and report them to the supplier within one working day.",
  "citations": [
    {
      "documentId": "doc-procedure",
      "title": "Receiving procedure",
      "locator": "Section 4, Damaged goods",
      "passage": "Damaged goods are photographed, moved to the quarantine bay and reported to the supplier within one working day."
    }
  ],
  "documentIds": [
    "doc-procedure"
  ],
  "code": null
}
```
