Skip to main content

Stress-test ideas with hundreds of AI personas. Adversarial multi-bias debate. API-first.

Project description

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

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

kranth-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

kranth-0.2.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kranth-0.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kranth-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5afab31ddfd985cf7b101fe333ce3a4a31c363df18f5e4cfaf450220f02d0be5
MD5 ef77cdc06a4c65941f3198d6f809ea5b
BLAKE2b-256 2b224fbb9b6c4096c8587faa22ce7925c4dfcd65a2d098a674723d7afbac6da5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kranth-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kranth-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b785667b896ab4e4274e8bc5df80e9d0fa58eb92911b2179615c77b7a772b0d5
MD5 3e5c87890edb8fb5cd772a2410024d38
BLAKE2b-256 e69fb7a1c8f6775aa0855686e407fb3ef643e0d0de6872932f7e32aa2a3f35db

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