Official Python SDK for the Kodari API
Project description
kodaripython
Official Python SDK for the Kodari API. Fully async, built on httpx.
Installation
pip install kodari
Quick Start
Get your API key at kodari.ai/api-keys.
import asyncio
from kodari import KodariClient, KodariCredentials
async def main():
async with KodariClient(KodariCredentials("kod-your-api-key")) as client:
result = await client.moderate("hello everyone")
if not result.safe:
print(f"Flagged: {result.category}") # toxicity, threat, doxxing, advertising, spam
print(f"Severity: {result.severity}") # low, medium, high
asyncio.run(main())
Moderation
Multilingual chat moderation AI that classifies messages for toxicity, threats, doxxing, spam, and advertising.
result = await client.moderate("some message")
result.safe # True/False
result.category # none, toxicity, threat, doxxing, advertising, spam
result.severity # none, low, medium, high
# Convenience checks
result.is_toxic
result.is_threat
result.is_doxxing
result.is_advertising
result.is_spam
Batch Moderation
Send 5+ messages for a 50% discount on token cost.
results = await client.moderate_batch([
"hello everyone",
"you're terrible at this game",
"check out my store at scam.com",
])
for r in results:
print(f"safe={r.safe} category={r.category}")
Generic Model Execution
Call any model by name, even ones added after your SDK version:
response = await client.execute("moderation", "your input")
response.kodari_model # "moderation"
response.tokens_cost # 10
response.result # raw dict
Session Flow (Code Generation)
session = await client.create_session("My Plugin", "minecraft", "plugin", "claude-sonnet-4-5")
gen = await client.generate(session.id, "Make a plugin that does X")
compiled = await client.compile(session.id)
jar_bytes = await client.download_jar(compiled.jar_id)
with open("plugin.jar", "wb") as f:
f.write(jar_bytes)
Other Endpoints
# Get current user
user = await client.get_me()
print(user.name, user.email)
Error Handling
All exceptions extend KodariException:
from kodari import (
KodariAuthenticationException,
KodariRateLimitException,
KodariInsufficientTokensException,
)
try:
result = await client.moderate("message")
except KodariAuthenticationException:
print("Invalid API key")
except KodariRateLimitException:
print("Rate limited, slow down")
except KodariInsufficientTokensException:
print("Not enough tokens")
Custom Configuration
client = KodariClient(
KodariCredentials("kod-your-api-key"),
base_url="http://localhost:8080",
user_agent="my-app/2.0",
)
Requirements
Python 3.10+
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file kodari-1.0.0.tar.gz.
File metadata
- Download URL: kodari-1.0.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f91704d49e466f1de4c44cad0463a1f3f5713abaa95de4f1bc8b495ffa4aa2bf
|
|
| MD5 |
dfa61664dcb91ea20f6f86ab80f27ada
|
|
| BLAKE2b-256 |
94c6558c218b926cd67351adc3c22f1a2f23f84ccc238db0b0d9c67c8da96830
|
File details
Details for the file kodari-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kodari-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5edd5fea3ab570735ecfdaa2d785558f0ef86d084bacd36524d32dddaa7c19d4
|
|
| MD5 |
b92100cde5eed883ad4dada206043228
|
|
| BLAKE2b-256 |
c52679d4d4df72aa679159f530dcd4f3d14965e2ffd6cb969f2dba06c9d382e8
|