Skip to main content

Multi-provider LLM gateway — one interface, every provider

Project description

llmshim

One interface, every LLM provider. The proxy server starts automatically — no setup needed.

Install

pip install llmshim

Configure

import llmshim

# Set API keys (writes to ~/.llmshim/config.toml — only needed once)
llmshim.configure(
    anthropic="sk-ant-...",
    openai="sk-...",
    gemini="AIza...",
    xai="xai-...",
)

Or from the CLI: llmshim configure

Chat

import llmshim

resp = llmshim.chat("claude-sonnet-4-6", "What is Rust?")
print(resp["message"]["content"])

With options:

resp = llmshim.chat(
    "openai/gpt-5.4",
    "Explain quicksort",
    max_tokens=500,
    temperature=0.7,
)

With message history:

resp = llmshim.chat("claude-sonnet-4-6", [
    {"role": "system", "content": "You are a pirate."},
    {"role": "user", "content": "Hello!"},
], max_tokens=500)

Streaming

for event in llmshim.stream("claude-sonnet-4-6", "Write a poem"):
    if event["type"] == "content":
        print(event["text"], end="", flush=True)
    elif event["type"] == "reasoning":
        pass  # thinking tokens
    elif event["type"] == "usage":
        print(f"\n[↑{event['input_tokens']}{event['output_tokens']}]")

Multi-Model Conversations

Switch models mid-conversation. History carries over.

messages = [{"role": "user", "content": "What is a closure?"}]

r1 = llmshim.chat("claude-sonnet-4-6", messages, max_tokens=500)
print(f"Claude: {r1['message']['content']}")

messages.append({"role": "assistant", "content": r1["message"]["content"]})
messages.append({"role": "user", "content": "Now explain differently."})

r2 = llmshim.chat("gpt-5.4", messages, max_tokens=500)
print(f"GPT: {r2['message']['content']}")

Reasoning / Thinking

resp = llmshim.chat(
    "claude-sonnet-4-6",
    "Solve: x^2 - 5x + 6 = 0",
    max_tokens=4000,
    reasoning_effort="high",
)
print(resp["reasoning"])        # thinking content
print(resp["message"]["content"])  # answer

Fallback Chains

resp = llmshim.chat(
    "anthropic/claude-sonnet-4-6",
    "Hello",
    max_tokens=100,
    fallback=["openai/gpt-5.4", "gemini/gemini-3-flash-preview"],
)

Other

llmshim.models()   # list available models
llmshim.health()   # {"status": "ok", "providers": [...]}

How It Works

On first call, the package:

  1. Finds the llmshim binary (bundled, on PATH, or in repo)
  2. Starts the proxy on a random localhost port
  3. Routes your request through it
  4. Server stops automatically when Python exits

No Docker, no background services, no manual server management.

Supported Models

Provider Models
OpenAI gpt-5.4
Anthropic claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5-20251001
Gemini gemini-3.1-pro-preview, gemini-3-flash-preview, gemini-3.1-flash-lite-preview
xAI grok-4-1-fast-reasoning, grok-4-1-fast-non-reasoning

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

llmshim-0.1.2.tar.gz (90.4 kB view details)

Uploaded Source

Built Distributions

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

llmshim-0.1.2-py3-none-win_amd64.whl (2.5 MB view details)

Uploaded Python 3Windows x86-64

llmshim-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

llmshim-0.1.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

llmshim-0.1.2-py3-none-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

llmshim-0.1.2-py3-none-macosx_10_12_x86_64.whl (2.5 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file llmshim-0.1.2.tar.gz.

File metadata

  • Download URL: llmshim-0.1.2.tar.gz
  • Upload date:
  • Size: 90.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llmshim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ec980d4091efc29974a029ce98bd23363f74cfb76e027032aba68cb63ece32a6
MD5 f9f8d393ac588653da88ba53fe7400a1
BLAKE2b-256 59f6148557ac579b89bb7a3324b496d3fa3a0a16747df655d651bf104cff1a82

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.2.tar.gz:

Publisher: release.yml on sanjay920/llmshim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmshim-0.1.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: llmshim-0.1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llmshim-0.1.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 cca95abb77fea7a07fb62b79898d259f8341dd63a98884042e2230aee7f9ede9
MD5 5d294b3c55b3e9347d254f35acf5b8e7
BLAKE2b-256 667819afa92607dbe25d67829204f791a49193c0fa709140c819c6e22264f151

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.2-py3-none-win_amd64.whl:

Publisher: release.yml on sanjay920/llmshim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmshim-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bec9f382fa73b2d39d3fe3b56101e17e29b26b5d27df3bb67f5de2a0cc4e7bd
MD5 60ae79d894735d7e4d1e3287cf47900c
BLAKE2b-256 07d425807f9dd68c79086925d17cdb1005f805fda6dea7a74f69388c7a0cef25

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on sanjay920/llmshim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmshim-0.1.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 454626d58dc5e89382c3760c28d8c498bf9068994e9aba164352f1b42e3d93b1
MD5 664e4ec1bbcafa20a5e903bcc8e5b49c
BLAKE2b-256 d2b750887dd953fc0d18e9fda061b9fa9266882049440d0de7d4c741b0085488

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on sanjay920/llmshim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmshim-0.1.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 39f8b07d383f6b3d833e6574db3f0f8eec1d2afc5df01ea6b2a8aad1781c8411
MD5 a47cb5870fc1edf329d4f635d2aaf97d
BLAKE2b-256 32da19ad5bc22fb1b2b99a9c7df529a49d429b8c38c306c17825d6656216f033

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.2-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on sanjay920/llmshim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmshim-0.1.2-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1462b0ba961be880e7ef71d2fe355c510cd5cf8961cdcb4e6b85f8bcd91b3dc3
MD5 7a3fec9446718703694f58bb7e9224c0
BLAKE2b-256 12a6cc9fc5dc50ce7132dae442e240443335db7074b2175f49df0395217fa40d

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.2-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on sanjay920/llmshim

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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