Skip to main content

Python SDK and CLI for the Verbatim platform — grounded, verbatim answers from curated document collections.

Project description

verbatim-client

PyPI version License

Python SDK and CLI for the Verbatim platform — grounded, verbatim answers from curated document collections.

Verbatim is a hosted RAG platform from KR Labs. Every answer is grounded in exact, citable spans from real documents. The platform is organized around collections — curated document sets like the ACL Anthology, or private collections we host for organizations.

This library is the Python client for talking to verbatim.krlabs.eu directly. It wraps the REST API with typed Pydantic responses and ships a verbatim command-line tool.

How it relates to the other Verbatim packages

Package What it's for
verbatim-client (this) Python SDK + CLI for the hosted platform
verbatim-rag Open-source RAG core to self-host your own Verbatim-style stack
verbatim-mcp MCP server wrapping the hosted platform for agentic clients
verbatim-skill Claude Code plugin exposing the platform as slash commands

Install

pip install verbatim-client

Get an API key

  1. Sign up at verbatim.krlabs.eu
  2. Navigate to API Keys, create a key
  3. Export it:
export VERBATIM_API_KEY=vb_your_key_here

SDK usage

Sync

from verbatim_client import VerbatimClient

with VerbatimClient() as client:
    # RAG over the default collection (ACL Anthology)
    result = client.query("What is the attention mechanism in transformers?")
    print(result.answer)
    for cite in result.structured_answer.citations:
        print(f"  [{cite.number}] {cite.text}")

    # Search papers (no LLM, no quota)
    papers = client.search_papers("attention mechanisms", year=2017, limit=5)
    for p in papers:
        print(p.id, p.title)

    # Search papers AND get the chunks that produced the match — useful for
    # feeding directly into a local extractor or your own pipeline. Free.
    papers = client.search_papers(
        "attention mechanisms", limit=5, include_chunks=True,
    )
    for p in papers:
        for chunk in p.matched_chunks or []:
            print(f"  [{chunk.score:.2f}] {chunk.text[:80]}…")

    # Paper detail + BibTeX + full text
    paper = client.get_paper("2017.acl-1.1")
    bibtex = client.get_paper_bibtex("2017.acl-1.1").bibtex
    content = client.get_paper_content("2017.acl-1.1").content

    # Browse facets
    venues = client.facets("venue", q="acl", limit=10)
    for v in venues.items:
        print(v.value, v.count)

    # Cross-collection query (when other collections are available)
    result = client.query(
        "Recent advances in language modeling",
        collection_ids=["anthology", "biorxiv"],
    )

Async

import asyncio
from verbatim_client import AsyncVerbatimClient

async def main():
    async with AsyncVerbatimClient() as client:
        result = await client.query("What is BERT?")
        print(result.answer)

asyncio.run(main())

Streaming

NDJSON streaming exposes documents → highlights → answer stages as they're produced:

with VerbatimClient() as client:
    for event in client.query_stream("What is BERT?"):
        if event["type"] == "documents":
            print(f"Retrieved {len(event['data'])} documents")
        elif event["type"] == "answer" and event.get("done"):
            print("Final answer:", event["data"]["answer"])

Verbatim Transform (bring your own context)

transform is collection-agnostic — pass your own context inline:

result = client.transform(
    "What are the main findings?",
    context=[
        {"content": "Full text of document 1...", "title": "Doc 1"},
        {"content": "Full text of document 2...", "title": "Doc 2"},
    ],
)
print(result.answer)

CLI

The package installs a verbatim command:

# Ask a question
verbatim query "What is BERT?"

# Search papers
verbatim search "attention mechanisms" --year 2017 --limit 5

# Search + include the matched chunks per paper (free, no LLM)
verbatim search "attention mechanisms" --include-chunks --json | jq '.[].matched_chunks'

# List collections
verbatim collections list

# Paper metadata, BibTeX, full text
verbatim paper get 2017.acl-1.1
verbatim paper bibtex 2017.acl-1.1 > vaswani-2017.bib
verbatim paper content 2017.acl-1.1 > vaswani-2017.md

# Facet autocomplete (fuzzy)
verbatim facets author --q vaswani --limit 5

# Verbatim transform over your own context
verbatim transform "What did they find?" --context ./mycontext.json

Every command honors VERBATIM_API_KEY and VERBATIM_API_URL from the environment; override per-invocation with --api-key and --base-url.

Add --json to most commands to get machine-readable output:

verbatim search "attention" --json | jq '.[] | {id, title}'

Configuration

Env var Default Description
VERBATIM_API_KEY Required. Your platform API key.
VERBATIM_API_URL https://verbatim.krlabs.eu API base URL. Override for dev / self-hosted.

Errors

API errors raise VerbatimError:

from verbatim_client import VerbatimClient, VerbatimError

try:
    client.query("...")
except VerbatimError as e:
    print(e.status_code, e.detail)

Common statuses:

  • 401 — authentication required
  • 403 — no access to this collection (or non-default collection while the platform's Milvus filter is disabled)
  • 404 — collection or paper not found
  • 429 — rate limit or quota exceeded
  • 451 — legal acceptance required

License

Apache 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

verbatim_client-0.2.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

verbatim_client-0.2.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file verbatim_client-0.2.0.tar.gz.

File metadata

  • Download URL: verbatim_client-0.2.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for verbatim_client-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0f931e2533a7f1cd6ce066e35e6decb77bcac2ba73abd9a426abc10b8bbf3a81
MD5 63bc2a834acdf5e1447f40467459a001
BLAKE2b-256 6f1b3e34b4901484215d65232f4cf51aee3ed59ffad538a60e15c7d9caeac1d2

See more details on using hashes here.

File details

Details for the file verbatim_client-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for verbatim_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 504cba66a2b4b36d5a627819d8fe8ffff5d6b61151313e36233fdc304643af9d
MD5 2a060a1035771c7daa01ae10a4d7ccd1
BLAKE2b-256 36bb3a51faaaac28b1e00461efdfce5c6e7d7f9e3a3b7bafe9650d02b11ce866

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page