# 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
    }
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.orbitfin.ai/orbit-api-reference/api/chat-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
