Skip to main content

Kranth — Python SDK

pip install kranth
from kranth import Kranth

client = Kranth(api_key="kr_live_…")

sim = client.sims.create(
    idea_text="We're launching a paid Rust devtool. $29/mo, hosted, no self-host.",
    persona_count=50,
    model_id="claude-sonnet-4-6",
)

for ev in client.sims.stream(sim.sim_id):
    if ev.kind == "persona.ready":
        print(f"persona {ev.data['persona_id']} ready")
    elif ev.kind == "reaction.complete":
        print(f"  → {ev.data['sentiment']:+.2f} {ev.data['persona_id']}")
    elif ev.kind == "sim.complete":
        report = ev.data.get("report") or {}
        print("verdict:", report.get("sentiment_score"))
        print("objections:")
        for o in report.get("top_objections", []):
            print("  ·", o)
        break

Async

import asyncio
from kranth import AsyncKranth

async def main():
    async with AsyncKranth(api_key="kr_live_…") as client:
        models = await client.models.list()
        sim = await client.sims.create(
            idea_text="…",
            persona_count=50,
            model_id=models[0].id,
        )
        async for ev in client.sims.stream(sim.sim_id):
            print(ev.kind)

asyncio.run(main())

Recon — web-grounded research

A swarm of agents researches your idea on the live web and returns a cited, scored verdict.

recon = client.recon.create(idea_text="Paid Rust devtool, $29/mo", tier="scout")
for ev in client.recon.stream(recon.recon_id):
    if ev.kind == "recon.complete":
        break
detail = client.recon.get(recon.recon_id)
print(detail.run.score, "·", len(detail.findings), "findings", len(detail.sources), "sources")

Debates — adversarial panel

debate = client.debates.create(topic="Should we kill the free tier?", mode="panel")
for ev in client.debates.stream(debate.id):
    if ev.kind == "debate.complete":
        break
d = client.debates.get(debate.id)
print(d.synthesis.score, d.synthesis.summary)

Resources

  • client.sims.create(...) — submit a sim
  • client.sims.get(sim_id) — single sim with status + verdict
  • client.sims.list(status=..., cursor=..., limit=...) — paginated
  • client.sims.stream(sim_id) — SSE event stream
  • client.sims.cancel(sim_id) — abort + refund unspent credits
  • client.sims.export(sim_id) — full report incl. reactions + clusters
  • client.recon.create(idea_text, tier, ...) / get / list / tiers / export / stream — web-grounded research
  • client.debates.create(topic, mode, ...) / get / list / turns / set_public / cancel / export / stream — adversarial panel
  • client.api_keys.create(name, env="live"|"test") — mint
  • client.api_keys.list() / client.api_keys.revoke(id)
  • client.models.list() — registry (id, tier, credits/100p, plan_min)
  • client.billing.usage() — credits consumed + remaining
  • client.billing.checkout_url(plan="pro", billing_period="monthly") — Stripe Checkout URL
  • client.billing.portal_url() — Stripe Customer Portal URL

Errors

from kranth import KranthPaymentRequired, KranthRateLimited

try:
    client.sims.create(...)
except KranthPaymentRequired:
    # out of credits — top up via client.billing.checkout_url("pro")
    ...
except KranthRateLimited as e:
    # over RPM — back off for e.retry_after seconds
    ...

Full exception tree: KranthError → KranthAPIError → {KranthAuthError, KranthValidationError, KranthPaymentRequired, KranthRateLimited}.

Configuration

client = Kranth(
    api_key="kr_live_…",
    base_url="https://api.kranth.ai",   # default
    timeout=30.0,
)

Bring your own httpx.Client if you need custom transport (proxies, mTLS, retries):

import httpx
client = Kranth(api_key="…", client=httpx.Client(transport=httpx.HTTPTransport(retries=3)))

License

Apache-2.0

Metadata

Release files for kranth 0.3.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 kranth 0.3.0
File Size Uploaded Provenance
kranth-0.3.0.tar.gz 9.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 23.6 kB

Release files / kranth-0.3.0.tar.gz

Download URL kranth-0.3.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2c017a4e6fa8cce6bff4c91f4e7b807076f8eb2dfe6ca6feac77301ec4728d7e
BLAKE2b-256 checksum
How to use checksums
a04def3666b36559fd440e98a03138817a00f56f3a09cd32922795d0416d6fc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / kranth-0.3.0-py3-none-any.whl

Download URL kranth-0.3.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1adbf624072bcd0ba6a3699663cb032e65aab915fa8157f16f81d784ca857fef
BLAKE2b-256 checksum
How to use checksums
7526ee9e04f2c0965383b0f4ea2469d0ede85f0bfa85a9666662dae309284c29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for kranth 0.3.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.

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

Release history Release notifications | RSS feed

This release

0.3.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