Metadata-Version: 2.4
Name: kodari
Version: 1.0.1
Summary: Official Python SDK for the Kodari API
Project-URL: Homepage, https://kodari.ai
Project-URL: Repository, https://github.com/KodariAI/kodaripython
Author-email: Kodari <support@kodari.ai>
License-Expression: MIT
Keywords: ai,api,kodari,moderation
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: httpx>=0.28.0
Description-Content-Type: text/markdown

# kodaripython

Official Python SDK for the [Kodari API](https://kodari.ai). Fully async, built on httpx.

## Installation

```bash
pip install kodari
```

## Quick Start

Get your API key at [kodari.ai/api-keys](https://kodari.ai/api-keys).

```python
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.

```python
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.

```python
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:

```python
response = await client.execute("moderation", "your input")

response.kodari_model  # "moderation"
response.tokens_cost   # 10
response.result        # raw dict
```

## Session Flow (Code Generation)

```python
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

```python
# Get current user
user = await client.get_me()
print(user.name, user.email)
```

## Error Handling

All exceptions extend `KodariException`:

```python
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

```python
client = KodariClient(
    KodariCredentials("kod-your-api-key"),
    base_url="http://localhost:8080",
    user_agent="my-app/2.0",
)
```

## Requirements

Python 3.10+
