Skip to main content

llmf

Free, keyless LLM chat in one call.

PyPI Python License: MIT

llmf (llmfree) talks to public, no-key OpenAI-compatible endpoints, picks a live one, and falls back automatically when something fails. Zero third-party dependencies — stdlib only. Works on desktop, server, and Termux.

import llmf

print(llmf.chat("Hello — who are you?"))

No API keys. No provider setup. Same return type every time.


Install

pip install -U llmf

Requires Python ≥ 3.8.

python -c "import llmf; print(llmf.__version__)"
llmf version

Quick start

import llmf

# Auto provider + model
llmf.chat("Summarize the CAP theorem in two sentences.")

# Intent shortcuts: fast | best | code | vision | reasoning
llmf.chat("Write a Python fibonacci function", model="code")

# Fuzzy or explicit model ids
llmf.chat("hi", model="llama")
llmf.chat("hi", model="ovh/Meta-Llama-3.3-70B-Instruct")

# Try models in order
llmf.chat("hi", model=["best", "fast"])

# Options
llmf.chat(
    "Return a JSON object with keys name and age",
    system="You only output valid JSON",
    max_tokens=300,
    temperature=0.2,
    json=True,
)

# Images (path, URL, or bytes)
llmf.chat("Describe this image", images=["photo.jpg"], model="vision")

# Streaming
for chunk in llmf.stream("Count from 1 to 5"):
    print(chunk, end="", flush=True)

chat() returns a Reply: behaves like a str, plus metadata (provider, model, attempts, …).


CLI

llmf "Your prompt here"
llmf chat "Explain recursion" --model best
llmf models              # built-in catalog
llmf models --live       # probe providers (network)
llmf providers
llmf health
llmf version

Local OpenAI-compatible proxy (stdlib HTTP server):

llmf serve --port 8000
# then: curl http://127.0.0.1:8000/v1/models

Defaults to 127.0.0.1 only. Use --host 0.0.0.0 only with --api-key. Use --cors if a browser extension must call it.


API surface

Function Purpose
llmf.chat(...) One-shot completion → Reply
llmf.stream(...) Token stream
llmf.achat / llmf.astream Async wrappers
llmf.session(system=...) Multi-turn conversation helper
llmf.models(live=False) List models
llmf.providers() List providers
llmf.health() Quick liveness checks
llmf.register(...) Add your own OpenAI-compatible base URL
llmf.discover() Opt-in scan for extra keyless endpoints
llmf.configure(...) Timeout, proxy, include/exclude providers
llmf.Client(...) Isolated client (no shared state)

Environment (optional):

Variable Effect
LLMF_TIMEOUT Default request timeout (seconds)
LLMF_PROXY HTTP(S) proxy for all requests
LLMF_MODEL Default model preference
llmf.configure(timeout=30, exclude=["blockrun"])
llmf.configure(proxy="http://127.0.0.1:8080")
llmf.register("lab", "http://localhost:11434/v1", ["llama3"], front=True)

How fallback works

  1. Prefer endpoints that are fast and clean in practice.
  2. On failure, cool down that target (e.g. longer after HTTP 429).
  3. Strip thinking / stats noise; treat empty “success” bodies as failures.
  4. If every target fails → llmf.AllProvidersFailed with per-provider .errors.

Built-in providers (availability changes over time): ChatJimmy, OVH, FreeAI, LLM7, Kilo/OpenRouter gateway, BlockRun, Pollinations, ChatAI, and others registered in the package. Always verify with llmf health / llmf models --live.


Safety notes

  • These are public, unofficial, free endpoints. They can rate-limit, change, or disappear without notice.
  • Do not send secrets, passwords, or personal data — prompts go to third-party servers.
  • discover() contacts external catalogs; treat it as opt-in.
  • Default local server binds to localhost and disables CORS on purpose.

Development

git clone https://github.com/MoonLite-Br/llmfree.git
cd llmfree
python -m unittest discover -s tests -v
python -m build && twine check dist/*

License

MIT — see LICENSE.

PyPI: pypi.org/project/llmf · Source: github.com/MoonLite-Br/llmfree

Metadata

Release files for llmf 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llmf 0.2.0
File Size Uploaded Provenance
llmf-0.2.0.tar.gz 39.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llmf 0.2.0
File Interpreter ABI Platform
llmf-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 79.5 kB

Release files / llmf-0.2.0.tar.gz

Download URL llmf-0.2.0.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9b1973822e40932f14946b5cd926d6f37b98d8570d2f3a7e6a650353a1d4942e
BLAKE2b-256 checksum
How to use checksums
aef4151d183b1e9acaeba037ca8876d06d6ab19c4103121ae506469ce337c773
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / llmf-0.2.0-py3-none-any.whl

Download URL llmf-0.2.0-py3-none-any.whl
Size 39.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d354f04b4521b2a759cde294b62d0a2ff2403ea2161d2472b2f8a2616ec15214
BLAKE2b-256 checksum
How to use checksums
22a49ff2b79cb6b145448e978c0cead1ae6311a9e208c5bc91d8aa72bfdef5ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for llmf 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page