Skip to main content

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 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.5.1

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

Source distribution (sdist)

Source distribution for fj-llm 0.5.1
File Size Uploaded Provenance
fj_llm-0.5.1.tar.gz 13.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fj-llm 0.5.1
File Interpreter ABI Platform
fj_llm-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / fj_llm-0.5.1.tar.gz

Download URL fj_llm-0.5.1.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
651e8329ed7acf6cd61334279d1cb56d1f3bd367d11d0673f3d851f25016d5a0
BLAKE2b-256 checksum
How to use checksums
0ca417cda1caf40852c326280083140474a92470b7fbb2edf4f6175cb52cffe5
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.5.1-py3-none-any.whl

Download URL fj_llm-0.5.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1bff1f7b051b323d141b01e9b6eefbdd3399866553048724b7b3cfabfb22da41
BLAKE2b-256 checksum
How to use checksums
8c36957ba0e454180e222642bae39ecf5ad047a7aeb3e74cc6a6c1fce45c74d5
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.5.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.

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