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.3.0.tar.gz (9.7 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.3.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kranth-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2c017a4e6fa8cce6bff4c91f4e7b807076f8eb2dfe6ca6feac77301ec4728d7e
MD5 cf36ff91898df9d44c42074f6d7f2a53
BLAKE2b-256 a04def3666b36559fd440e98a03138817a00f56f3a09cd32922795d0416d6fc3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for kranth-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1adbf624072bcd0ba6a3699663cb032e65aab915fa8157f16f81d784ca857fef
MD5 6fc1564913438cc95f2afd637559dc16
BLAKE2b-256 7526ee9e04f2c0965383b0f4ea2469d0ede85f0bfa85a9666662dae309284c29

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