Skip to content

Document Query

POST /v1/document_query

Enables natural conversational interactions with documents stored in SmartBuckets. This endpoint allows users to ask questions, request summaries, and explore document content through an intuitive conversational interface. The system understands context and can handle complex queries about document contents.

The query system maintains conversation context throught the request_id, enabling follow-up questions and deep exploration of document content. It works across all supported file types and automatically handles multi-page documents, making complex file interaction as simple as having a conversation.

The system will:

  • Maintain conversation history for context when using the same request_id
  • Process questions against file content
  • Generate contextual, relevant responses

Document query is supported for all file types, including PDFs, images, and audio files.

Request Body Parameters

ParameterTypeRequiredDescription
bucket_locationobjectYesThe storage bucket containing the target document. Must be an accessible Smart Bucket
object_idstringYesDocument identifier within the bucket. Typically matches the storage path or key
inputstringYesUser’s input or question about the document. Can be natural language questions, commands, or requests
request_idstringYesClient-provided conversation session identifier. Required for maintaining context in follow-up questions. We recommend using a UUID or ULID for this value.

Responses

200

AI-generated response that may include direct document quotes, content summaries, contextual explanations, references to specific sections, and related content suggestions

Returns a DocumentQueryResponse object with the following properties:

PropertyTypeDescription
answerstringAI-generated response that may include direct document quotes, content summaries, contextual explanations, references to specific sections, and related content suggestions

400

Invalid request parameters or malformed request

Returns a Error object with the following properties:

PropertyTypeDescription
codeintegerError code that maps to standard Connect/gRPC error codes
messagestringHuman-readable error message with error code prefix

401

Missing or invalid authentication

Returns a Error object with the following properties:

PropertyTypeDescription
codeintegerError code that maps to standard Connect/gRPC error codes
messagestringHuman-readable error message with error code prefix

403

Insufficient permissions to access the requested resource

Returns a Error object with the following properties:

PropertyTypeDescription
codeintegerError code that maps to standard Connect/gRPC error codes
messagestringHuman-readable error message with error code prefix

404

Requested resource not found

Returns a Error object with the following properties:

PropertyTypeDescription
codeintegerError code that maps to standard Connect/gRPC error codes
messagestringHuman-readable error message with error code prefix

500

Internal server error

Returns a Error object with the following properties:

PropertyTypeDescription
codeintegerError code that maps to standard Connect/gRPC error codes
messagestringHuman-readable error message with error code prefix
import Raindrop from '@liquidmetal-ai/lm-raindrop';
const client = new Raindrop({
apiKey: process.env['RAINDROP_API_KEY'], // This is the default and can be omitted
});
async function main() {
const response = await client.documentQuery.ask({
bucket_location: { module_id: '01jtgtrd37acrqf7k24dggg31s' },
input: 'What is the key points in this document?',
object_id: 'object_id',
request_id: '123e4567-e89b-12d3-a456-426614174000',
});
console.log(response.answer);
}
main();

Response Examples

{
"answer": "The key points in this document are..."
}