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.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 fj-llm 0.5.0
File Size Uploaded Provenance
fj_llm-0.5.0.tar.gz 12.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 21.7 kB

Release files / fj_llm-0.5.0.tar.gz

Download URL fj_llm-0.5.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d97015ecf14b6a8c913a99493bad75c12fba6645961b75aa8f94b9cd2c9ba888
BLAKE2b-256 checksum
How to use checksums
e9cbdf0fd895d8c00bc257c45716cab42d12ac93c8a64a88c63e5891543d4a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / fj_llm-0.5.0-py3-none-any.whl

Download URL fj_llm-0.5.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8173ea7efb7702027ffec55354a5fb76c4e04eee5ed2de2fd757931df80efb8
BLAKE2b-256 checksum
How to use checksums
a2bee9828dab65c8493db7b2a54d9a269d30de930d0aa0f5ebd033b19b8376d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for fj-llm 0.5.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.

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