Skip to main content

togolm

Minimal Python client for the TogoLM API.

Requires Python 3.9+. Built on httpx.

Install

pip install togolm

Get an API key

from togolm import TogoLM

client = TogoLM()  # no key needed for this call
result = client.register_key(email="you@example.com", name="Your Name")
api_key = result["api_key"]  # shown once — save it

You can also call client.query(...) without a key — public access is rate-limited (see rate limits).

Usage

from togolm import TogoLM

client = TogoLM(api_key="your_api_key")

result = client.query("Comment créer une entreprise au Togo ?")
print(result["answer"], result["sources"])

Streaming

for event in client.query_stream("Comment créer une entreprise au Togo ?"):
    if event["type"] == "chunk":
        print(event["text"], end="")
    if event["type"] == "sources":
        print("Sources:", event["sources"])

Multi-turn conversations

history = []
for question in ["Comment créer une entreprise au Togo ?", "Et pour les impôts ?"]:
    result = client.query(question, history=history)
    history.append({"role": "user", "content": question})
    history.append({"role": "assistant", "content": result["answer"]})

history is capped at 20 messages server-side; oldest first. max_tokens (default 3000, 50–4096) caps the generated answer length.

Local development

Point at a local API instead of production:

client = TogoLM(base_url="http://localhost:8000/v1")

Error handling

Non-2xx responses raise TogoLMError (status and body attributes):

from togolm import TogoLM, TogoLMError

try:
    client.query("...")
except TogoLMError as err:
    print(err.status, err.body)

Context manager

TogoLM holds an httpx.Client; use it as a context manager to close it automatically:

with TogoLM(api_key="your_api_key") as client:
    result = client.query("...")

All methods

Method Description
query(question, category=None, language=None, max_tokens=None, history=None) RAG query, full response
query_stream(question, category=None, language=None, max_tokens=None, history=None) RAG query, SSE stream (generator)
embed(text) Generate an embedding vector
search(q) Full-text search over the corpus
categories() List available corpus categories
stats() Public corpus statistics
documents(page=None, page_size=None, category=None, source=None, language=None) Paginated document list
document(doc_id) Document detail, including chunks
register_key(email, name, use_case=None) Request a free API key
me() Current API key info and usage
close() Close the underlying HTTP client

Full request/response shapes: API reference.

Metadata

Release files for togolm 0.1.2

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

Source distribution (sdist)

Source distribution for togolm 0.1.2
File Size Uploaded Provenance Actions
togolm-0.1.2.tar.gz 3.6 kB Without provenance Details for togolm-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for togolm 0.1.2
File Interpreter ABI Platform Actions
togolm-0.1.2-py3-none-any.whl Python 3 none any Details for togolm-0.1.2-py3-none-any.whl

Total release size: 7.6 kB

Release files / togolm-0.1.2.tar.gz

Download URL togolm-0.1.2.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
68973bfa60649d08dc8fb8d4f0b86d6b74457689f02d86df2a15c75d658e2a10
BLAKE2b-256 checksum
How to use checksums
b0be88289c452193fd58e90a7125815cf132df0ef02c34daf1f1ba1e3b8000c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / togolm-0.1.2-py3-none-any.whl

Download URL togolm-0.1.2-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b98112e8f272864f516397c587ce8cfc6d25ceb2a2849f3da50382ee0aad5d4d
BLAKE2b-256 checksum
How to use checksums
69dabf90297852cb35fd870e7d389fdc89f84f44d71a7687a16ceae3a78ced0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for togolm 0.1.2

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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