Skip to main content

Minimal universal LLM client - swap providers with one env var

Project description

Universal LLM Client

Swap LLM providers with one env var. No code changes.

from universal_llm import Settings, get_client

settings = Settings(provider="anthropic", model="claude-3-haiku")
client = get_client(settings)

resp = client.chat_sync([
    {"role": "user", "content": "Explain the CAP theorem in 2 sentences."}
])
print(resp)

Installation

pip install universal-llm[all]

Or install only what you need:

  • pip install universal-llm[openai]
  • pip install universal-llm[anthropic]
  • pip install universal-llm[google]
  • pip install universal-llm[ollama]

Configuration

Set via environment variables:

  • LLM_PROVIDER - openai, anthropic, google, or ollama
  • LLM_MODEL - model name
  • LLM_API_KEY - API key (not required for Ollama)
  • LLM_BASE_URL - base URL (Ollama defaults to http://localhost:11434/v1)
  • LLM_TEMPERATURE - temperature (default: 0.2)
  • LLM_TIMEOUT - timeout in seconds (default: 60)

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

universal_llm-0.1.0.tar.gz (79.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

universal_llm-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file universal_llm-0.1.0.tar.gz.

File metadata

  • Download URL: universal_llm-0.1.0.tar.gz
  • Upload date:
  • Size: 79.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for universal_llm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7ca194c680bffefa222432cb9bf0f04f014a7f920c3039e8f543229658d97144
MD5 f4300013a71b709239c6d73a4a694e8a
BLAKE2b-256 9efc9d82978ec580a87d2839b536fc1c3ed2f192de47c3bf1a363261f7c82e4b

See more details on using hashes here.

File details

Details for the file universal_llm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: universal_llm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for universal_llm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 286261e68a17e03ef645bdcefbfd3998247cf5e71cb552e6b0cf366e82cb5634
MD5 c0a48b55ad46bfbeece2b22c054e216a
BLAKE2b-256 eeb8ad119891d3e7ec0593840296662a2ea137f0f46afee7df48dca19666c84d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page