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

Uploaded Python 3Windows x86-64

llmshim-0.1.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

llmshim-0.1.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

llmshim-0.1.7-py3-none-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

llmshim-0.1.7-py3-none-macosx_10_12_x86_64.whl (3.2 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: llmshim-0.1.7.tar.gz
  • Upload date:
  • Size: 99.5 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.7.tar.gz
Algorithm Hash digest
SHA256 e0e2f9c8944c9e47f1a6f0756202f697f4dc19cebbf3b2f109029b7bd2d337a9
MD5 3b7af203bc3b47b71f4f5a0ebf1718a8
BLAKE2b-256 1bce881329d539ebdadbfa5025d648943686dd2460ed8e81e825fda95c320bda

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: llmshim-0.1.7-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 69d9ab8bc89c27e4c8d1acc49a77d8a92c78e8599894d74f7487b98e4da9980c
MD5 a1844c73f2b16ce491389af36a956247
BLAKE2b-256 3e8100dedae46afc6900cf145e7a6af4013183b9e403f825fceef178992102d3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c4c0a5eff2d9259a07c4a630c10fcfe86bf90cefaf70cce3f76346beba78f4db
MD5 44579a12aee2c9aaca3050d515bd6728
BLAKE2b-256 0970ecd159fa83426c67a76c5eb3d07be1dce83eff6faae7d272525871694f7c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2123603e59750bef295ec8fe09c1cad0f84d3e5c1b367223dbdc630a22b09b35
MD5 3aa6d649e90707a7580e1967b1585971
BLAKE2b-256 496fa5670bde2e26c0942950c3ec2d7cd2580615cac41210ee71d3c373f1ca9e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 667e4704dfb167bb5731f578481610c0e5b4a2e4567fde01d8e79087bf7e7aa5
MD5 e9965663f6fc0ec3b0f758bd8dab3cd7
BLAKE2b-256 dbb314eee5fcfeb0a60defb690bc851c6a365ca73aa770b1b9a62648f7a83a60

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.7-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0355edd9ed133a711147a410c72201de7efe1f1a99f4c1390841ff5f38152d37
MD5 4af2c4bcd2bad6ec32bb15b2eef4f2cb
BLAKE2b-256 41683bd6a0f1add598b5d282bddf3fa50f1e966d785db08b417cff42207e1846

See more details on using hashes here.

Provenance

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