Get RAG space chunks
This endpoint retrieves relevant chunks from processed files in a space based on a search query. It is designed for Retrieval-Augmented Generation (RAG) use cases where you need to find specific content within files in a space.
You must provide:
- The space ID in the path
- A search query as a query parameter
- The user ID in the headers
- The tenant ID in the headers
- The API key in the headers
Access Control:
Access to the space's files chunk list depends on your permissions and the space's visibility:
- Private Spaces: Only accessible by the space owner
- Public Spaces: Accessible by all users within the same tenant
The files must belong to the specified space. Files cannot be accessed through a different space than the one they were uploaded to.
Optionally, pass fileIds to restrict the search to a subset of files within the space. This filter is always combined
with the space scope, so it can only narrow results to files already inside the specified space — it cannot be used to
reach files belonging to a different space or tenant.
The endpoint returns the most relevant chunks from the files in the space that match your query, which can be used to provide context to language models or for semantic search functionality.
Authorization
ApiTokenAuth PRODUCT, GEN_AIAPI Key with role based permission
In: header
Scope: PRODUCT, GEN_AI
Path Parameters
The ID of the space to retrieve chunks from
Query Parameters
The search query to find relevant chunks in the file
Maximum number of chunks to return
Comma-separated list of file IDs to restrict the search to. Only chunks from files that belong to both the specified space and this list are returned; files from other spaces are never matched.
Header Parameters
The ID of the user requesting the file chunks
The ID of the tenant
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X GET "https://example.com/v1/spaces/497f6eca-6276-4993-bfeb-53cbbbba6f08/rag?query=string&fileIds=123e4567-e89b-12d3-a456-426614174000%2C223e4567-e89b-12d3-a456-426614174000" \ -H "x-user-id: string" \ -H "x-tenant-id: string"[
{
"content": "Introduction to Machine Learning: Machine learning is a subset of artificial intelligence that focuses on the development of algorithms and statistical models that enable computers to improve their performance on tasks through experience...",
"metadata": {
"file_id": "123e4567-e89b-12d3-a456-426614174000",
"user_id": "user-abc-123",
"file_name": "machine_learning_guide.pdf",
"tenant_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"chunk_id": "123e4567-e89b-12d3-a456-426614174000_chunk_0",
"space_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"embedding_model": "amazon.titan-embed-text-v2:0"
},
"score": 0.92
},
{
"content": "Deep Learning Fundamentals: Neural networks are computing systems inspired by biological neural networks. They consist of layers of interconnected nodes that process information...",
"metadata": {
"file_id": "123e4567-e89b-12d3-a456-426614174000",
"user_id": "user-abc-123",
"file_name": "machine_learning_guide.pdf",
"tenant_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"chunk_id": "123e4567-e89b-12d3-a456-426614174000_chunk_7",
"space_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"embedding_model": "amazon.titan-embed-text-v2:0"
},
"score": 0.85
}
]{
"message": "Query parameter is required"
}{
"message": "Invalid API Key"
}{
"message": "Space not found"
}{
"message": "Internal Server Error"
}