A slim, intuitive, lightweight Python library for calling LLMs (high-level + low-level) with multi-provider support.
Project description
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”: explicitClient,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)
git clone https://github.com/slimx-ai/slimx.git
cd slimx
uv sync --all-extras
Option B — quick test from an extracted zip
unzip slimx_v0_4.zip
cd slimx_v0_4
uv sync --all-extras
uv run python examples/quickstart_openai.py
uv syncreadspyproject.tomland (optionally)uv.lock. Ifuv.lockis present and committed, installs are reproducible.
Configure providers
OpenAI
export OPENAI_API_KEY="..."
# optional:
export OPENAI_BASE_URL="https://api.openai.com/v1"
Google Gemini
export GOOGLE_API_KEY="..."
# or:
export GEMINI_API_KEY="..."
# optional:
export GOOGLE_BASE_URL="https://generativelanguage.googleapis.com/v1beta"
Anthropic
export ANTHROPIC_API_KEY="..."
# optional:
export ANTHROPIC_BASE_URL="https://api.anthropic.com"
export ANTHROPIC_VERSION="2023-06-01"
Ollama (local)
export OLLAMA_BASE_URL="http://localhost:11434"
Quickstart (high-level)
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)
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:
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):
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:
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slimx-0.5.0.tar.gz.
File metadata
- Download URL: slimx-0.5.0.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a94e76e559f7fa99caa8086e72a7c74096d046511b9d28a3b23ce2da2c7237a9
|
|
| MD5 |
d45c3e8b3115be413ace2608a789e152
|
|
| BLAKE2b-256 |
d6b917045fe880c6bbba94c9d2cb56a0494a794ab231eab79520e1735fe80e80
|
File details
Details for the file slimx-0.5.0-py3-none-any.whl.
File metadata
- Download URL: slimx-0.5.0-py3-none-any.whl
- Upload date:
- Size: 32.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3682c322aeb1bc9a61a8005267aa8eabb1d640dff01aabaa243e2c5c0096cc53
|
|
| MD5 |
e524ac45678b1be373f31f9cf6784651
|
|
| BLAKE2b-256 |
ae5a9b9f9fbe00a70f8f46de00a3cd47bb6ffbba4f750661fb7f07fe1a3ed120
|