Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Googleapis Python genai Documents

From Leeroopedia
Knowledge Sources
Domains RAG, Document_Management
Last Updated 2026-02-15 14:00 GMT

Overview

Concrete tool for managing documents within file search stores provided by the Google Gen AI SDK.

Description

The Documents and AsyncDocuments classes provide API modules for retrieving, deleting, and listing documents stored in file search stores (RAG stores). These are accessed as a sub-resource of FileSearchStores and support both Gemini Developer API and Vertex AI backends.

Usage

Import these classes when you need to manage documents within a file search store for retrieval-augmented generation (RAG) workflows, such as listing indexed documents, getting document metadata, or removing documents from a store.

Code Reference

Source Location

Signature

class Documents(_api_module.BaseModule):
    def get(
        self,
        *,
        name: str,
        config: Optional[types.GetDocumentConfigOrDict] = None,
    ) -> types.Document: ...

    def delete(
        self,
        *,
        name: str,
        config: Optional[types.DeleteDocumentConfigOrDict] = None,
    ) -> None: ...

    def list(
        self,
        *,
        parent: str,
        config: Optional[types.ListDocumentsConfigOrDict] = None,
    ) -> Pager[types.Document]: ...

Import

from google import genai
client = genai.Client(api_key="...")
# Access via: client.file_search_stores.documents

I/O Contract

Inputs

Name Type Required Description
name str For get/delete Document resource name
parent str For list File search store resource name
config GetDocumentConfigOrDict / DeleteDocumentConfigOrDict / ListDocumentsConfigOrDict No Operation-specific configuration

Outputs

Name Type Description
get() returns Document Document metadata and details
list() returns Pager[Document] Paginated list of documents

Usage Examples

from google import genai

client = genai.Client(api_key="GEMINI_API_KEY")

# List documents in a file search store
for doc in client.file_search_stores.documents.list(
    parent="fileSearchStores/my-store-id"
):
    print(f"{doc.name}: {doc.display_name}")

# Get specific document
doc = client.file_search_stores.documents.get(
    name="fileSearchStores/my-store-id/documents/my-doc-id"
)

# Delete a document
client.file_search_stores.documents.delete(
    name="fileSearchStores/my-store-id/documents/my-doc-id"
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment