Metadata-Version: 2.4
Name: khazai
Version: 0.1.0
Summary: Simple AI chat client with memory and multi-model support
Author: khazuly
License-Expression: MIT
Project-URL: Homepage, https://github.com/khazuly/chatai
Project-URL: Source, https://github.com/khazuly/chatai
Project-URL: Tracker, https://github.com/khazuly/chatai/issues
Keywords: ai,chat,gpt,claude,gemini,openai,llm
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.31
Dynamic: requires-python

# khazai

> Unofficial Python client for AI chat — simple, lightweight, with memory.

```python
from khazai import Client

ai = Client(system="Kamu adalah asisten yang membantu.")
print(ai(prompt="Halo!", memory=True))
```

## Features

- **Simple API** — just `Client()` + `ai(prompt="...")`
- **System prompt** — set persona once or override per-call
- **Memory** — conversation history with automatic summarization & session rotation
- **Multiple models** — GPT, Claude, Gemini, DeepSeek, Grok, Qwen
- **Streaming** — real-time token generation
- **Auto session** — fresh cookies & CSRF on limit (2000 tokens) or rate-limit (429)

## Install

```bash
pip install khazai
```

## Usage

### Quick start

```python
from khazai import Client

ai = Client()
reply = ai(prompt="hello")
print(reply)
```

### With system prompt

```python
ai = Client(system="You are a helpful assistant. Be concise.")

reply = ai(prompt="explain quantum computing")
```

### Memory mode

```python
ai = Client(system="You are a friendly chatbot.")

ai(prompt="my name is Rizky", memory=True)
ai(prompt="what is my name?", memory=True)
# "Your name is Rizky."
```

### Change model

```python
# Short names
ai = Client(model="gpt")       # default
ai = Client(model="claude")
ai = Client(model="gemini")
ai = Client(model="deepseek")
ai = Client(model="grok")

# Override per-call
ai(prompt="hello", model="claude")

# Full model ID
ai = Client(model="openai/gpt-4o-mini")
```

Available: `gpt`, `claude`, `gemini`, `deepseek`, `grok`, `qwen`.

### Streaming

```python
for chunk in ai(prompt="tell me a story", stream=True):
    print(chunk, end="", flush=True)
```

### Per-call system prompt

```python
ai(prompt="who are you?", system="You are a French assistant. Answer in French.")
# "Je suis votre assistant virtuel..."
```

### Stateless (no memory)

```python
reply = ai(prompt="hello")             # memory=False by default
reply = ai(prompt="hello", memory=False)
```

Each stateless call rotates the session and discards history.

### CLI

```bash
python -m khazai "your prompt here"
```

```bash
python -m khazai
> hello
Hello! How can I help you?
> /quit
```

## Interactive example

```python
from khazai import Client

ai = Client(system="Kamu adalah customer service yang ramah.")

while True:
    msg = input("> ")
    if msg == "quit":
        break
    print(ai(prompt=msg, memory=True))
```

## Models

| Short name       | Full ID                                  |
|------------------|------------------------------------------|
| `gpt`            | `openai/gpt-4o-mini`                     |
| `claude`         | `anthropic/claude-haiku-4-5`             |
| `gemini`         | `google/gemini-2.0-flash-001`            |
| `deepseek`       | `deepseek/deepseek-chat-v3-0324`         |
| `grok`           | `x-ai/grok-3-mini-beta`                  |
| `qwen`           | `qwen/qwen-2.5-72b-instruct`             |

## License

MIT
