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 simclient.sims.get(sim_id)— single sim with status + verdictclient.sims.list(status=..., cursor=..., limit=...)— paginatedclient.sims.stream(sim_id)— SSE event streamclient.sims.cancel(sim_id)— abort + refund unspent creditsclient.sims.export(sim_id)— full report incl. reactions + clustersclient.recon.create(idea_text, tier, ...)/get/list/tiers/export/stream— web-grounded researchclient.debates.create(topic, mode, ...)/get/list/turns/set_public/cancel/export/stream— adversarial panelclient.api_keys.create(name, env="live"|"test")— mintclient.api_keys.list()/client.api_keys.revoke(id)client.models.list()— registry (id, tier, credits/100p, plan_min)client.billing.usage()— credits consumed + remainingclient.billing.checkout_url(plan="pro", billing_period="monthly")— Stripe Checkout URLclient.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
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
kranth-0.3.0-py3-none-any.whl
(13.9 kB
view details)
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c017a4e6fa8cce6bff4c91f4e7b807076f8eb2dfe6ca6feac77301ec4728d7e
|
|
| MD5 |
cf36ff91898df9d44c42074f6d7f2a53
|
|
| BLAKE2b-256 |
a04def3666b36559fd440e98a03138817a00f56f3a09cd32922795d0416d6fc3
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1adbf624072bcd0ba6a3699663cb032e65aab915fa8157f16f81d784ca857fef
|
|
| MD5 |
6fc1564913438cc95f2afd637559dc16
|
|
| BLAKE2b-256 |
7526ee9e04f2c0965383b0f4ea2469d0ede85f0bfa85a9666662dae309284c29
|