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.3.tar.gz (90.1 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.3-py3-none-win_amd64.whl (2.5 MB view details)

Uploaded Python 3Windows x86-64

llmshim-0.1.3-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.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

llmshim-0.1.3-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.3.tar.gz.

File metadata

  • Download URL: llmshim-0.1.3.tar.gz
  • Upload date:
  • Size: 90.1 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.3.tar.gz
Algorithm Hash digest
SHA256 51f3358447ec1653a044e3c1b2e047524b0e26930a412382c5b6fc7bf05cf77e
MD5 51abbffafbecfc28a159a0bc2ec4fb76
BLAKE2b-256 e85f706c6c149b7326209591ad24e536bb210667228cfd5a8306c8fa93849f9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.3.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.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: llmshim-0.1.3-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.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e60affa52cb614065dbbc8d8ac14eb3e61f191777fb9c1c1e342d0ba02032f5b
MD5 0c145a4d3ac407013d2fd6cd4eacc1c9
BLAKE2b-256 737db6528c6864439d65d164a0a6e459ec910b2f4a66c210c08e8014928a6077

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.3-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.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68ba0979008aec8206fdf34cd76f2ce66afc7472ee6e0a6c1377932af954741b
MD5 78e267f1c3e0f76a013efb7e57d67107
BLAKE2b-256 411d383a8802db451036ed5633379591667f1d5543c049738c0d1fba65b0e2bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.3-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.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 38951535d696aa14fb7fa066287f7256c0091dbb2976ffa5c1e51b6ae11f5a1f
MD5 6fe9be56cf06ceb75769d7781aae103f
BLAKE2b-256 626e95ee796ec29ffd420e0aca1ea9b18eed58fdb1cda35638411ecbc5276e84

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.3-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.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b86fe2b6451038e5a6deb7138cdaefd3f3dd260a9fc01383f776f9a803544cad
MD5 c8ae7c3e16a5581a2a0c73c6f581c433
BLAKE2b-256 6ec53f66f04eb4686e8c029601d674dc1a6b8a4dcda27f463f378a5cefa0ce1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.3-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.3-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for llmshim-0.1.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e77bbdf084c145576a0c7d1babc72d66f43216db8cc59521acf85ff3c840cfda
MD5 aa9b612505afc2f871c9aa3e65915466
BLAKE2b-256 e4ab91c69af1bd51ff6cf04079f1fbb1a6a97af54f6333d3ec2cc986d1a787b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmshim-0.1.3-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