> For the complete documentation index, see [llms.txt](https://docs.orbitfin.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.orbitfin.ai/orbit-api-reference/api/chat-query.md).

# Chat Query

### 6. Chat Query

Interactive AI-powered chat for company research.

#### Endpoint

```
POST /chat/query
```

#### Parameters

| Parameter         | Type      | Required | Description                             |
| ----------------- | --------- | -------- | --------------------------------------- |
| messages          | array     | Yes      | Chat history with role and content      |
| orbit\_entity\_id | string\[] | No       | Limit to specific companies (max: 5)    |
| knowledge\_base   | string    | No       | filings, news, all (default: filings)   |
| temperature       | float     | No       | Response creativity (0-1, default: 0.3) |

#### Example Request

bash

```bash
curl -X POST "https://api.orbitfin.ai/v1/chat/query" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "Compare Apple and Microsoft R&D spending trends"
      }
    ],
    "orbit_entity_id": ["ent_2vxp8q3n", "ent_7kms9p2w"]
  }'
```

#### Response

json

```json
{
  "status": "success",
  "credits_used": 1.0,
  "data": {
    "response": "Based on the latest 10-K filings...",
    "citations": [
      {
        "source": "AAPL 10-K 2024",
        "page": 45,
        "text": "Research and development expense was $29.9 billion"
      }
    ],
    "usage": {
      "prompt_tokens": 156,
      "completion_tokens": 892,
      "total_tokens": 1048
    }
  }
}
```
