curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/ai/tools/documents/ask \
--header 'Authorization: Bearer <token>' \
--header 'content-type: <content-type>' \
--data '
{
"fileIds": [
{
"id": 123
}
],
"question": "<string>",
"additionalContext": "<string>",
"ignoreUnknownIds": false,
"language": "English"
}
'{
"content": [
{
"text": "<string>",
"references": [
{
"fileId": 123,
"fileName": "<string>",
"locations": [
{
"bottom": 123,
"left": 123,
"pageNumber": 123,
"right": 123,
"top": 123
}
],
"externalId": "<string>",
"instanceId": {
"externalId": "<string>",
"space": "<string>"
}
}
]
}
]
}This API endpoint uses a language model to answer questions about documents. Provided with a natural language question and a list of files, the API returns a multi-part answer with references to the locations in the documents that were used to build the answer.
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/ai/tools/documents/ask \
--header 'Authorization: Bearer <token>' \
--header 'content-type: <content-type>' \
--data '
{
"fileIds": [
{
"id": 123
}
],
"question": "<string>",
"additionalContext": "<string>",
"ignoreUnknownIds": false,
"language": "English"
}
'{
"content": [
{
"text": "<string>",
"references": [
{
"fileId": 123,
"fileName": "<string>",
"locations": [
{
"bottom": 123,
"left": 123,
"pageNumber": 123,
"right": 123,
"top": 123
}
],
"externalId": "<string>",
"instanceId": {
"externalId": "<string>",
"space": "<string>"
}
}
]
}
]
}Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
A list of file IDs, external IDs, or instance IDs pointing to PDF documents
1 - 100 elementsShow child attributes
The question to ask about the documents.
1 - 2048Optional additional context that the model can use to improve its answer
10 - 2048If true, the API will not fail if any documents are missing or not fully processed, but generate an answer based on available documents.
The language in which the answer should be provided.
Chinese, Dutch, English, French, German, Italian, Japanese, Korean, Latvian, Norwegian, Portuguese, Spanish, Swedish Successful Response
The content of an answer consists of one or more parts. Each part can have a different set of document locations connected to it.
Show child attributes
Was this page helpful?