Goatlab API Docs

Get RAG file chunks

GET
/v1/files/{file_id}/rag

This endpoint retrieves relevant chunks from a processed file based on a search query. It is designed for Retrieval-Augmented Generation (RAG) use cases where you need to find specific content within a file.

You must provide:

  • The file ID in the path
  • A search query as a query parameter
  • The user ID in the headers

The endpoint returns the most relevant chunks from the file that match your query, which can be used to provide context to language models or for semantic search functionality.

Authorization

ApiTokenAuth PRODUCT, GEN_AI
x-api-key<token>

API Key with role based permission

In: header

Scope: PRODUCT, GEN_AI

Path Parameters

file_id*string

The ID of the file to retrieve chunks from

Query Parameters

query*string

The search query to find relevant chunks in the file

limit?integer

Maximum number of chunks to return

Header Parameters

x-user-id*string

The ID of the user requesting the file chunks

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/v1/files/497f6eca-6276-4993-bfeb-53cbbbba6f08/rag?query=string" \  -H "x-user-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": null,
      "chunk_id": "123e4567-e89b-12d3-a456-426614174000_chunk_0",
      "space_id": null,
      "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": null,
      "chunk_id": "123e4567-e89b-12d3-a456-426614174000_chunk_7",
      "space_id": null,
      "embedding_model": "amazon.titan-embed-text-v2:0"
    },
    "score": 0.85
  }
]
{
  "message": "Query parameter is required"
}
{
  "message": "Invalid API Key"
}
{
  "message": "File with ID '123e4567-e89b-12d3-a456-426614174000' not found"
}
{
  "message": "Internal Server Error"
}