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

Tool Use / Function Calling

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current weather",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]

resp = llmshim.chat("claude-sonnet-4-6", "Weather in Tokyo?", max_tokens=500, tools=tools)
for tc in resp["message"].get("tool_calls", []):
    print(f"{tc['function']['name']}({tc['function']['arguments']})")

Tools are accepted in OpenAI Chat Completions format and auto-translated to each provider's native format.

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

llmshim-0.1.4-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.4.tar.gz.

File metadata

  • Download URL: llmshim-0.1.4.tar.gz
  • Upload date:
  • Size: 91.7 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.4.tar.gz
Algorithm Hash digest
SHA256 9bc938c30e60630ffc8423f265f314315a1ca5bd26e2795d09adc2b6d3cb20f1
MD5 07f430ba24f2e5c76116a4e078ff8f9a
BLAKE2b-256 f1a79622b62b5cccf8dfd47db15bc41fb8f5fa543eb3c246aa91e56c395d517f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: llmshim-0.1.4-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.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6e97ef750a4d84efd624d35d3f97c642c11c59cf88a837356be27237e7bad608
MD5 391964653c655a84b60da01398c4f605
BLAKE2b-256 6054c15297733ca622c95a2aae3f3754c42fc8c166894deb3fd8da6ecf89abcc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 726c8f4b0fec39d9fac7af3f4995d3b2e07eaf058c6f74ce18996fc1688a3ae7
MD5 0e7bfa724ea4eec2931d06941f4b7aa6
BLAKE2b-256 2050fc83d3e1b54f17a1e6d6056b9ef247b8daaf4e6dda71c12156ebd62481cf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a305b8430fe01473a4b581af0e9783bb7a3248db89d6b399f17b1832ccb4caad
MD5 67222f42d09117fd233e1d1e1dbdefab
BLAKE2b-256 0afc4eeb890f74f0c40d0441093f1363ed9fa304ef8616d9e5f229b5a078c209

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 429237d3cdb8913576c50da6abe03bfc5f8991fdd41d30cc4977382d45298721
MD5 3cf5e698d6c5e514ebeb904840865cab
BLAKE2b-256 6fcec8ac52c86dee1fabba634ccff7e79118a6b6fd47fe8c21c711a50d9d73ba

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 999e1a947bca6d682b6e990c8a729f1cc4cd15c05b3fbe16cc7479f0206612fb
MD5 2306ca781456f90bef7e8082cb77182a
BLAKE2b-256 6625a8e4f91099d40e1ca8e73d6b121f354b202d6efef3b930e26b67b68f9f1b

See more details on using hashes here.

Provenance

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