Metadata-Version: 2.4
Name: slimx
Version: 0.5.0
Summary: A slim, intuitive, lightweight Python library for calling LLMs (high-level + low-level) with multi-provider support.
Author: SlimX Contributors
License: MIT License
        
        Copyright (c) 2026 SlimX
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: anthropic,llm,ollama,openai,sdk,streaming,tools
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: pyright>=1.1.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Requires-Dist: twine>=5.0.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
Requires-Dist: mkdocs>=1.6.0; extra == 'docs'
Description-Content-Type: text/markdown

# SlimX (`slimx`) — v0.5.0

SlimX is a **slim, intuitive, lightweight** Python library for calling LLMs and building LLM systems.

It is intentionally designed around **two clearly separated APIs**:

- **High-level API** (`slimx`) — “1‑minute productivity”: `llm(...)`, `.stream(...)`, `.json(...)`, tools, retries.
- **Low-level API** (`slimx.low`) — “systems builder primitives”: explicit `Client`, `ChatRequest`, `Message`, provider registry, middleware.

SlimX also supports **multiple providers** (OpenAI, Anthropic, Ollama, Google) and **provider plugins** (3rd-party providers without modifying core).

---

## Install (using `uv`)

On Debian/Ubuntu you may hit `externally-managed-environment` (PEP 668) if you try to use system `pip`.
Use **uv**, which manages an isolated environment cleanly.

### Option A — contributors / repo setup (recommended)
```bash
git clone https://github.com/slimx-ai/slimx.git
cd slimx
uv sync --all-extras
```

### Option B — quick test from an extracted zip
```bash
unzip slimx_v0_4.zip
cd slimx_v0_4
uv sync --all-extras
uv run python examples/quickstart_openai.py
```

> `uv sync` reads `pyproject.toml` and (optionally) `uv.lock`.
> If `uv.lock` is present and committed, installs are reproducible.

---

## Configure providers

### OpenAI
```bash
export OPENAI_API_KEY="..."
# optional:
export OPENAI_BASE_URL="https://api.openai.com/v1"
```

### Google Gemini

```bash
export GOOGLE_API_KEY="..."
# or:
export GEMINI_API_KEY="..."

# optional:
export GOOGLE_BASE_URL="https://generativelanguage.googleapis.com/v1beta"
```

### Anthropic
```bash
export ANTHROPIC_API_KEY="..."
# optional:
export ANTHROPIC_BASE_URL="https://api.anthropic.com"
export ANTHROPIC_VERSION="2023-06-01"
```

### Ollama (local)
```bash
export OLLAMA_BASE_URL="http://localhost:11434"
```

---

## Quickstart (high-level)

```python
from slimx import llm
m = llm("openai:gpt-4.1-nano", temperature=0.2)
res = m("Write a haiku about fog and streetlights.")
print(res.text)
```

```python
from slimx import llm

m = llm("google:gemini-3.5-flash", temperature=0.2)
res = m("Write a haiku about small, inspectable AI software.")
print(res.text)
```

Streaming:

```python
for ev in m.stream("Tell a short story in 5 lines."):
    if ev.type == "text_delta":
        print(ev.text, end="", flush=True)
print()
```

Tools (auto-loop):

```python
from slimx import llm, tool

@tool
def add(a: int, b: int) -> int:
    "Add two integers."
    return a + b

m = llm("openai:gpt-4.1-nano", tools=[add], tool_runtime="auto")
print(m("What is 12 + 30?").text)
```

Structured output:

```python
from dataclasses import dataclass
from slimx import llm

@dataclass
class City:
    name: str
    country: str

m = llm("openai:gpt-4.1-nano")
res = m.json("Paris is in France.", schema=City)
print(res.data)
```

---

## Repo automation

This bundle includes GitHub Actions:
- CI (`.github/workflows/ci.yml`)
- Docs deploy to GitHub Pages (`docs.yml`)

See `README.md` and `docs/` for details.
