POST
/
agents
/
{agent_id}
/
query
curl --request POST \
  --url https://api.contextual.ai/v1/agents/{agent_id}/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "messages": [
    {
      "content": "<string>",
      "role": "user"
    }
  ],
  "stream": false,
  "conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "llm_model_id": "<string>",
  "structured_output": {
    "type": "JSON",
    "json_schema": {}
  },
  "documents_filters": {
    "filters": [
      {
        "field": "field1",
        "operator": "equals",
        "value": "value1"
      }
    ],
    "operator": "AND"
  }
}'
{
  "conversation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "message_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "message": {
    "content": "<string>",
    "role": "user"
  },
  "retrieval_contents": [
    {
      "number": 1,
      "type": "<string>",
      "format": "pdf",
      "content_id": "<string>",
      "doc_id": "<string>",
      "doc_name": "<string>",
      "page": 123,
      "content_text": "<string>",
      "url": "<string>",
      "score": 123
    }
  ],
  "attributions": [
    {
      "start_idx": 123,
      "end_idx": 123,
      "content_ids": [
        "<string>"
      ]
    }
  ],
  "groundedness_scores": [
    {
      "start_idx": 123,
      "end_idx": 123,
      "score": 123
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

agent_id
string
required

Agent ID of the agent to query

Query Parameters

retrievals_only
boolean
default:false

Set to true to fetch retrieval content and metadata, and then skip generation of the response.

include_retrieval_content_text
boolean
default:false

Set to true to include the text of the retrieved contents in the response. If false, only metadata about the retrieved contents will be included, not content text. This parameter is ignored if retrievals_only is true, in which case content_text will always be returned. Content text and other metadata can also be fetched separately using the /agents/{agent_id}/query/{message_id}/retrieval/info endpoint.

Body

application/json

Request body for a POST /agents/{agent_id}/query request

Response

200
application/json

Successful Response

Response body for POST /query