Skip to main content

Python SDK

Coming Soon

The official Python SDK is under active development. In the meantime, the REST API works with any HTTP client.

Planned Installation

pip install inherent

Using the API Today

Install requests:

pip install requests

Wrapper Client

Drop this into your project and use it as a lightweight SDK until the official one ships.

import requests
import time
from typing import Optional


class InherentClient:
"""Lightweight wrapper around the Inherent Public API."""

def __init__(
self,
api_key: str,
base_url: str = "https://api.inherent.systems/api/v1",
):
self.base_url = base_url.rstrip("/")
self.session = requests.Session()
self.session.headers.update({
"X-API-Key": api_key,
"Content-Type": "application/json",
})

def _request(self, method: str, path: str, **kwargs) -> dict:
resp = self.session.request(method, f"{self.base_url}{path}", **kwargs)
resp.raise_for_status()
return resp.json()

# ── Documents ──────────────────────────────────────────────

def upload_document(
self,
file_path: str,
metadata: Optional[dict] = None,
) -> dict:
"""Upload a document for ingestion."""
with open(file_path, "rb") as f:
files = {"file": f}
data = {}
if metadata:
data["metadata"] = str(metadata)
# multipart upload — don't send JSON content-type
resp = self.session.post(
f"{self.base_url}/documents",
files=files,
data=data,
headers={"X-API-Key": self.session.headers["X-API-Key"]},
)
resp.raise_for_status()
return resp.json()

def list_documents(self, limit: int = 20, offset: int = 0) -> dict:
"""List documents in the workspace."""
return self._request(
"GET", "/documents", params={"limit": limit, "offset": offset}
)

def get_document(self, document_id: str) -> dict:
"""Get a single document by ID."""
return self._request("GET", f"/documents/{document_id}")

# ── Search ─────────────────────────────────────────────────

def search(self, query: str, limit: int = 10) -> dict:
"""Semantic search across your workspace."""
return self._request(
"POST", "/search", json={"query": query, "limit": limit}
)

# ── Chunks ─────────────────────────────────────────────────

def get_chunks(self, document_id: str) -> list:
"""Get all chunks for a document."""
return self._request("GET", f"/chunks/{document_id}")

def get_context(self, document_id: str) -> dict:
"""Get contextual chunks for a document."""
return self._request("GET", f"/chunks/{document_id}/context")

# ── Health ─────────────────────────────────────────────────

def health(self) -> dict:
"""Check API health."""
return self._request("GET", "/health")

Complete Example

Upload a document, wait for processing, search, and retrieve context:

from inherent_client import InherentClient  # or paste the class above

client = InherentClient(api_key="ink_your_api_key_here")

# 1. Upload a document
doc = client.upload_document("./knowledge-base/architecture.md")
document_id = doc["document_id"]
print(f"Uploaded: {document_id} — status: {doc['status']}")

# 2. Wait for ingestion to complete
while True:
info = client.get_document(document_id)
status = info["status"]
print(f" Processing: {status}")
if status in ("completed", "ready"):
break
if status in ("failed", "error"):
raise RuntimeError(f"Ingestion failed: {info}")
time.sleep(2)

# 3. Search across the workspace
results = client.search("How does authentication work?", limit=5)
for chunk in results["chunks"]:
print(f"[{chunk['score']:.3f}] {chunk['content'][:120]}...")

# 4. Get full context for the top result
top_doc_id = results["chunks"][0]["document_id"]
context = client.get_context(top_doc_id)
print(f"\nContext window ({len(context['chunks'])} chunks):")
for c in context["chunks"]:
print(f" - {c['content'][:80]}...")

Using with LangChain / LlamaIndex

The client returns plain dicts, so it plugs into any framework:

# Build a context string for your LLM
results = client.search("deployment process", limit=5)
context = "\n\n---\n\n".join(
chunk["content"] for chunk in results["chunks"]
)

# Pass to your LLM
prompt = f"""Answer based on the following context:

{context}

Question: How do I deploy to production?"""

Stay Updated

Star the GitHub repo to get notified when the official SDK launches.