Metadata-Version: 2.4
Name: anchorai-sdk
Version: 0.1.1
Summary: Official Python client and local web chat UI for Anchor AI (Fathom-1)
License-Expression: MIT
Project-URL: Homepage, https://anchorcloud.org
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31
Dynamic: license-file

# anchorai-sdk

Official Python client and local web chat UI for **Anchor AI (Fathom-1)** —
Anchor Cloud's self-hosted assistant. Uses the same `ac_live_...` API key as
the [anchorcloud](https://pypi.org/project/anchorcloud/) library, since both
authenticate against the same account on `anchorcloud.org`.

## Install

```bash
pip install anchorai-sdk
```

## Chat UI (recommended)

Launches a polished local web chat interface in your browser — nothing runs
except on your own machine, and the only outbound calls are to
`anchorcloud.org` using your API key.

```bash
anchorai --api-key ac_live_...
# or: set ANCHORCLOUD_API_KEY in your environment, then just: anchorai
```

Opens `http://127.0.0.1:8420` automatically. Options:

```bash
anchorai --api-key ac_live_... --port 9000 --no-browser
```

## Library usage

```python
from anchorai import AnchorAI

client = AnchorAI(api_key="ac_live_...")

reply = client.ask("Organize my vault into folders by file type")
print(reply)

for m in client.history():
    print(m["role"], ":", m["message"])
```

`client.send(message)` returns the full response dict from the server
(`{"reply": ..., "type": ...}`, occasionally including a `files` list for
download requests); `client.ask(message)` is a shortcut that just returns the
reply text.

## Getting an API key

Same key as the `anchorcloud` library: `dashboard.anchorcloud.org` → **API
Keys** → **Generate New Key**. One key works for both file storage and chat,
since they share the same account and auth.

## Error handling

```python
from anchorai import AnchorAI, AuthError, ApiError

try:
    client = AnchorAI(api_key="ac_live_...")
    client.ask("hello")
except AuthError:
    print("Key is missing, malformed, or was revoked.")
except ApiError as e:
    print(f"Server error ({e.status_code}): {e}")
```

## Requirements

- Python 3.9+
- `requests`

## License

MIT — see [LICENSE](LICENSE).
