# GH0ST Qwen Python client

A synchronous Python client for the GH0ST local Qwen API. It uses only the Python standard library at runtime. Start the model API separately; this package does not download a model or launch a server.

From the Agent Kit directory:

```sh
python3 -m pip install ./python
```

From your own Python project:

```python
from gh0st_qwen import GH0STQwen

client = GH0STQwen()
answer = client.generate(
    "Welcome a new developer to our community in two sentences.",
    system="Use clear, concise language.",
    max_tokens=128,
)
print(answer)
```

The default API is `http://127.0.0.1:8790/v1`. HTTP is accepted only for loopback hosts; use HTTPS for a remote server. An optional `api_key` becomes a bearer Authorization header. No key is needed by the default local server. Redirects are rejected to avoid forwarding prompts or keys to another destination. Failed requests are not retried automatically.

Use `client.chat(messages, max_tokens=256, temperature=0.3)` to obtain the full response, including usage and `gh0st` provenance metadata. Supported messages contain only `role` (`system`, `user`, or `assistant`) and string `content`; output is non-streaming. `max_tokens` ranges from 1 to 512 and `temperature` from 0 to 1. `client.models()` reads the available models.

Catch `GH0STError` for request failures, `GH0STAPIError` for HTTP errors (`status_code`, optional `code`), and `GH0STConnectionError` for network failures/timeouts. Invalid local arguments raise `ValueError`. Requests contain at most 24 messages and 12000 UTF-8 bytes; responses are limited to 128 KiB. The server also enforces its own bounds.

Run the external example while the API is running:

```sh
python3 python/examples/chat.py "Explain what a community agent does."
```

The example prints the actual response or exits with an error. It does not supply fallback or fixture text. This API runs local model inference; it provides no on-chain execution proof or production token billing. GH0ST provides the interface. Qwen's model weights and upstream license remain separate.

From a source checkout that includes `python/tests/`, run client tests without a model server:

```sh
PYTHONPATH=python/src python3 -m unittest discover -s python/tests -v
```
