Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kodari-1.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

kodari-1.0.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file kodari-1.0.1.tar.gz.

File metadata

  • Download URL: kodari-1.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for kodari-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a62b44443f65f8885802aad80310513f479fcdf4b14af19087078aa68745b09b
MD5 c185f1a468f04b0e78a1b1018ed1b710
BLAKE2b-256 bc41b3da67ea31878d655c235b8c552155f778cbcddca00c2e3844e2101b773e

See more details on using hashes here.

File details

Details for the file kodari-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: kodari-1.0.1-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

Hashes for kodari-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52f395b55c2f382d248e581a300481d72504464c117f0791121063455b8a7f18
MD5 9171c1c5c75acd991645fa708eadcb3c
BLAKE2b-256 cfcc5b3bfcbca50440e3d33ba7ea6a1c0cd5874497b7cb6e09579e258cb5e24a

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