Skip to main content

Overview

The moorcheh-client package provides a Python client for calling the Moorcheh on-prem API, plus the moorcheh CLI for starting the runtime and running the same operations from the shell. No API keys are required — the client talks directly to your local Moorcheh instance.

Package

PyPImoorcheh-client
Importfrom moorcheh import MoorchehClient, MoorchehApiError
CLImoorcheh (installed with the same package)
pip install moorcheh-client

Start the server

moorcheh up
Default API base URL: http://localhost:8080 Use MoorchehClient with resource modules — same layout as the cloud Python SDK:
from moorcheh import MoorchehClient

with MoorchehClient("http://localhost:8080") as client:
    client.namespaces.create("my-docs", type="text")
    client.documents.upload("my-docs", documents=[{"id": "d1", "text": "..."}])
    client.documents.fetch_text_data("my-docs", limit=100)
    client.similarity_search.query(namespaces=["my-docs"], query="...")
    client.answer.generate(namespace="my-docs", query="...")
ArgumentDefaultDescription
base_urlhttp://localhost:8080Moorcheh API URL (trailing slash is stripped)
timeout30Request timeout in seconds

Resources

ResourceMethodsDescription
client.health()Server status and global item quota
client.namespacescreate, list, delete, delete_job_statusNamespace management
client.documentsupload, get, delete, fetch_text_data, upload_job_statusText documents and chunks
client.vectorsupload, delete, upload_job_statusPrecomputed vector data
client.filesupload, list, get, delete, job_statusPath-based file upload (on-prem)
client.similarity_searchquerySemantic search
client.answergenerateRAG or direct LLM answers

Legacy flat client

MoorchehApiClient remains available for backward compatibility:
from moorcheh import MoorchehApiClient

client = MoorchehApiClient("http://localhost:8080")
client.upload_namespace_documents("my-docs", {"documents": [...]})
All flat methods delegate to MoorchehClient resources internally.

Errors

Non-2xx HTTP responses raise MoorchehApiError with:
  • status_code — HTTP status (for example 400, 404, 409)
  • body — parsed JSON error body when available
  • is_item_limit_exceededTrue for 409 quota errors on uploads
from moorcheh import MoorchehClient, MoorchehApiError

try:
    with MoorchehClient() as client:
        client.documents.upload("my-docs", documents=[...])
except MoorchehApiError as exc:
    if exc.is_item_limit_exceeded:
        print("Global item cap reached:", exc.body)
    else:
        print(f"Error ({exc.status_code}): {exc}")

Next steps