iQ Suite - Docs
SDK ReferenceDocument RAG

Retrieve

Retrieve information based on a query from a specific index.

Description

The /index/retrieve endpoint allows you to query a specific index and retrieve relevant information based on your query. This is useful for fetching detailed data from your indexed documents.

HTTP Request

POST /index/retrieve

Authentication

All requests must include an Authorization header with a valid API key.

Headers

KeyValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Request Body

  • index: The ID of the index to query.
  • query: The query string to retrieve information.
  • document_id: Pass in the document Id to restrict the retrieval context to the mentioned document only OPTIONAL

JSON

FieldTypeDescription
indexstringThe ID of the index to query
querystringThe query string
document_idstringThe Document ID to restrict the retrieval context to the mentioned document only (OPTIONAL)

Request Example

try:
# Send a natural language query to the specified index
response = client.retrieve(
    index_id='your-index-id',
    query="What are the main points discussed in the document?",
    document_id="your-document-id" # Optional, you can filter and retrieve results from the specific document.
)
# Print the response from the platform
print(f"Response: {response}")
except APIError as e:
# Handle any API-related errors
print(f"Error: {e}")

Response

Success

Status Code: 200 OK

Body:

{
   "data": {
       "uuid": "53bbc0f9-948f-4229-8f28-ce55ad462911",
       "query": "Where can we find snow peaks in India",
       "retrieval_response": "Insufficient context",
       "sources": null,
       "credits_cost": 0.07,
       "total_tokens": 1955,
   }
}

On this page