Skip to main content

Talkory: AI answer comparison and consensus platform. Official Python SDK.

Project description

talkory

Official Python SDK for Talkory.ai: ask once, hear from five LLMs (GPT, Claude, Gemini, Grok, Perplexity), get a consensus answer.

pip install talkory

Quickstart

Create an API key at app.talkory.ai (Settings → API Keys), then:

from talkory import Talkory

client = Talkory()  # reads TALKORY_API_KEY from the environment

result = client.queries.run("Best commuter motorcycles under $5000?")
print(result.consensus)       # synthesized consensus answer
print(result.common_answer)   # what the models agreed on
print(result.confidence)      # 0-100
print(result.charged)         # USD charged for this run

queries.run() blocks until the run finishes (can take a few minutes; the read timeout defaults to 600s per the API docs).

Streaming

Watch all five models answer live over Server-Sent Events:

for event in client.queries.stream("Compare Python web frameworks in 2026"):
    if event.type == "model_chunk":
        print(event.chunk, end="", flush=True)
    elif event.type == "done":
        print("\n\nConsensus:", event.consensus)

Events arrive as typed objects (query_created, model_stream_start, model_chunk, model_result, model_error, consensus_start, done, and more), so your IDE autocompletes the fields per event type. If the connection drops after the run starts, the SDK raises StreamInterruptedError carrying query_id; the run keeps going server-side, so recover with client.queries.retrieve(err.query_id) instead of re-running (which would charge twice).

Async

AsyncTalkory mirrors the entire client:

import asyncio
from talkory import AsyncTalkory

async def main():
    async with AsyncTalkory() as client:
        result = await client.queries.run("Best NAS for home use?")
        print(result.consensus)

        async for event in client.queries.stream("..."):
            if event.type == "model_chunk":
                print(event.chunk, end="")

        async for q in client.queries.list(limit=10):
            print(q.id, q.prompt)

asyncio.run(main())

Fire-and-forget + poll

run = client.queries.create("Compare Python web frameworks in 2026")
result = client.queries.wait(run.id)      # polls with gentle backoff

Choosing models

models = client.models.list()             # free
result = client.queries.run(
    "Is a heat pump worth it in Delhi?",
    models=["gpt", "claude"],             # subset (max 10)
    recursive=True,                       # round-2 self-review before consensus
    country="in",                         # localization
)

Free endpoints

client.health.check()                     # LLM provider health
client.wallet.get()                       # balance
client.usage.get(from_="2026-06-01")      # usage stats for this key
client.queries.retrieve(query_id)         # past result by id
for q in client.queries.list(limit=50):   # auto-paginating history
    print(q.id, q.prompt, q.charged)

Deferred consensus

result = client.queries.run("...", consensus=False)   # cheaper
later = client.queries.consensus(result.id)           # idempotent; cached re-calls charge $0

Errors

Every documented API error maps to a typed exception carrying code, status, message, and request_id (quote the request_id in support tickets):

from talkory import RateLimitError, InsufficientBalanceError, TalkoryError

try:
    result = client.queries.run("...")
except RateLimitError as e:
    time.sleep(e.retry_after or 30)
except InsufficientBalanceError:
    ...  # top up at app.talkory.ai
except TalkoryError as e:
    print(e.code, e.request_id)

Wallet safety

The SDK never auto-retries paid POST requests. If a connection drops after a run starts, the run still completes (and charges) server-side, and retrying blindly would double-spend your wallet. On timeout/disconnect, check client.queries.retrieve(id) first. Free idempotent GETs are retried automatically on 429/500/503, honoring Retry-After.

Security

  • Key resolution: explicit api_key= argument → TALKORY_API_KEY env var. The SDK never reads or writes keys to disk.
  • Keys are redacted everywhere they could leak: repr(), exception messages, logs show tk_live_***a1b2 at most.
  • HTTPS is enforced; a plain-HTTP base_url is refused unless you explicitly pass allow_insecure=True (local testing only).
  • Zero telemetry: the SDK makes no network calls other than the API requests you invoke. The only metadata sent is User-Agent: talkory-python/{version} python/{py_version}.
  • Never embed keys in frontend/browser code; call Talkory from your backend.

See SECURITY.md for vulnerability reporting.

Requirements

Python 3.9+ · httpx · pydantic v2. Fully typed (py.typed).

Links

License

MIT

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

talkory-0.0.5.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

talkory-0.0.5-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file talkory-0.0.5.tar.gz.

File metadata

  • Download URL: talkory-0.0.5.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for talkory-0.0.5.tar.gz
Algorithm Hash digest
SHA256 b6032471c81e84343671e1e83af40e0e5faf8387ff7a482cf5231e7d7ddba746
MD5 4b10dbf150c1645559143981a4ed33c8
BLAKE2b-256 affffb40fd6dd20ef5cc5a07abc3c14ca8b04e790f2c83aad0a1bac7b31052d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for talkory-0.0.5.tar.gz:

Publisher: main.yaml on talkory-ai/talkory-python-pip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file talkory-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: talkory-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for talkory-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 408f8f45e04fb4e071a2e13b2587fbc7c0a8d095ba6e2e4ca84f6c13579cdcbf
MD5 23e8bed47fdc138a561a4d6bd55837de
BLAKE2b-256 782ab5dae124b65df1ae6ca5dd0cbf6c791cebff7c0ffedacb36218dbfb7de15

See more details on using hashes here.

Provenance

The following attestation bundles were made for talkory-0.0.5-py3-none-any.whl:

Publisher: main.yaml on talkory-ai/talkory-python-pip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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