fj-llm
Lightweight, config-driven Python client for multiple LLM providers. One interface, any provider — no provider SDK required.
Install
pip install fj-llm
Providers
| Provider | Config key | Env var |
|---|---|---|
| OpenAI | openai |
OPENAI_API_KEY |
| Anthropic | anthropic |
ANTHROPIC_API_KEY |
| DeepSeek | deepseek |
DEEPSEEK_API_KEY |
google |
GOOGLE_API_KEY |
Configuration
On first use, a default config is created at ~/.config/fj_llm/config.yaml. Edit it to add your API keys and define model aliases:
models:
gpt-best:
provider: openai
model_name: gpt-4o
api_key_env: OPENAI_API_KEY
base_url: https://api.openai.com/v1
max_tokens: 4000
temperature: 0.1
pricing:
input_per_1m_tokens: 2.50
output_per_1m_tokens: 10.00
fallback: gpt-light # optional: alias to use on quota exhaustion
gpt-light:
provider: openai
model_name: gpt-4o-mini
api_key_env: OPENAI_API_KEY
base_url: https://api.openai.com/v1
max_tokens: 4000
temperature: 0.1
pricing:
input_per_1m_tokens: 0.15
output_per_1m_tokens: 0.60
defaults:
retry_attempts: 3
retry_delay: 1.0
timeout: 30
For Cloud Functions or other environments without filesystem access, set the FJ_LLM_CONFIG environment variable to a JSON string of the same structure.
Usage
from fj_llm import LLMClient
client = LLMClient()
response = client.query("gpt-best", "Summarise this in one sentence.", context=long_text)
if response.success:
print(response.content)
print(f"Cost: ${response.cost:.6f}")
else:
print(f"Error: {response.error}")
Cost logging
Every successful call is appended as a JSONL record to ~/.local/share/fj_llm/costs.jsonl. Override the path via the FJ_LLM_COST_LOG env var, or set cost_log in the config file.
CLI
llm-query gpt-best "What is the capital of France?"
License
MIT
Metadata
Release files for fj-llm 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fj_llm-0.6.1.tar.gz | 13.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fj_llm-0.6.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.9 kB
Release files / fj_llm-0.6.1.tar.gz
| Download URL | fj_llm-0.6.1.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cddf343f7da9150aa93fe090dd3493a6341c72e3e15cc2869d9603bcaa9f4f74
|
|
BLAKE2b-256 checksum How to use checksums |
f599c5219b72e258f2cbcf9e88b96d27596b28fb2d353e8223aca91f7a4456ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Release files / fj_llm-0.6.1-py3-none-any.whl
| Download URL | fj_llm-0.6.1-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88a5b375b24b671eed2b787afa41ae9107c84a5a670dca59d8e4bb04f3c5008e
|
|
BLAKE2b-256 checksum How to use checksums |
1ec549d665bfcca278631346178deca837c0785471e9b5b9429ffecec3c55899
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Security for fj-llm 0.6.1
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.