Skip to main content

lightrag-client

Python SDK for the InfraX RAGservicer — hybrid knowledge-base (vector + graph + keyword) retrieval over REST.

Install

pip install lightrag-client

Quick Start

from lightrag_client import LightRAGClient

rs = LightRAGClient(base_url="http://localhost:9721", api_key="lr_xxx", tenant_id="market")

# Insert documents (async by default → returns {task_id, status, doc_id})
rs.insert("market", "BTC 走势受美联储利率政策影响", "doc-1")
rs.insert_batch("market", [
    {"text": "DeFi TVL 回升", "doc_id": "doc-2"},
    {"text": "链上巨鲸增持", "doc_id": "doc-3"},
])
# ⚠️ 写入为异步:后台完成「抽实体建图 + 向量化」后才可检索到。
# 写入后建议轮询 GET /api/v1/namespaces/<ns>/tasks/<task_id> 至 index_status=indexed
# (任务 status=success 仅代表写入完成,不代表索引完成;index_status=error 表示索引失败需重放)
# (端到端样例见 examples/lightrag_store_and_query.py)

# Query (context retrieval, no LLM answer)
result = rs.query("market", "比特币走势")
print(result["context"])
print(result["sources"])      # [{"id": "doc-1", "name": "doc-1", "score": 0.82}, ...]
print(result["topScore"])     # 0.82(可用于置信度路由;无分数时为 None)
print(result["scoreSource"])  # "embedding" | "unavailable"

# Context-only retrieval with top_k(with_scores=False 可省掉补算分数的 embedding 调用)
ctx = rs.retrieve("market", "利率", top_k=5)
fast = rs.retrieve("market", "利率", top_k=5, with_scores=False)

# Documents
rs.list_documents("market", page=1, limit=20)
print(rs.get_document("market", "doc-1"))   # {doc_id, status, chunks, updated_at, error, ...}
rs.delete("market", "doc-1")

Admin

# Tenants & API keys
rs.create_tenant("market", "Market Data", "default tenant")  # 幂等:已存在返回 created=False
rs.get_tenant("market")        # 租户详情 + namespaces/documents/indexed/failed 计数
rs.generate_api_key("market", "prod", expires_days=90)
rs.list_api_keys("market")

# Hot-reload LLM / Embedding config (no restart needed)
rs.update_config(llm={"api_key": "sk-new", "model": "deepseek-chat"})

All methods talk the standard InfraX envelope {code, message, data} and return the data payload on success; API failures raise LightRAGClientError with .status / .code / .message.

Requirements

  • Python >= 3.9
  • requests

License

MIT

Metadata

Release files for lightrag-client 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lightrag-client 2.1.0
File Size Uploaded Provenance
lightrag_client-2.1.0.tar.gz 5.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lightrag-client 2.1.0
File Interpreter ABI Platform
lightrag_client-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / lightrag_client-2.1.0.tar.gz

Download URL lightrag_client-2.1.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1dcc97c092811c55a30e6ef39a366d3649c45df57f337cb5d633e923fe450528
BLAKE2b-256 checksum
How to use checksums
c2168132a9c6f59ef236d9052ff2d9ae02c7e300436b831d9dea50e6f9747a5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / lightrag_client-2.1.0-py3-none-any.whl

Download URL lightrag_client-2.1.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5824add0a491e9b7477fcff67ce88fb188db003378db760a50c5009e8e444c3
BLAKE2b-256 checksum
How to use checksums
0d28df8ca4cebe45edba563707d6fd51f80a67b5bdc67e0163c1f9f817976f5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for lightrag-client 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page