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

# Ask

> Ask questions over indexed video or collection context.

## Endpoints

```http theme={null}
POST /video/{video_id}/ask/
POST /collection/{collection_id}/ask/
```

Use `ask()` when you want a generated answer grounded in indexed video context.

## Request body

| Field             |    Type | Required | Description                                                           |
| ----------------- | ------: | -------: | --------------------------------------------------------------------- |
| `question`        |  string |      yes | Question to answer from indexed video context.                        |
| `top_k`           | integer |       no | Number of retrieved candidate moments. Defaults to `15`.              |
| `mode`            |  string |       no | Search mode used for source retrieval. Defaults to `"default"`.       |
| `include_sources` | boolean |       no | Include supporting source shots in the response. Defaults to `false`. |

`ask()` does not accept index selectors such as `index_name`, `index_names`, `index_id`, or `index_ids`.

## Example

```python theme={null}
answer = collection.ask(
    question="Which brands are mentioned and what is said about them?",
    top_k=15,
    mode="default",
    include_sources=True,
)

print(answer.answer)

for source in answer.sources:
    print(source.video_id, source.start, source.end)
```

## Response

Returns an `AskResponse`.

| Attribute | Description                                            |
| --------- | ------------------------------------------------------ |
| `answer`  | Generated answer text.                                 |
| `sources` | Supporting `Shot` objects when `include_sources=True`. |
