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

Uploaded Python 3Windows x86-64

llmshim-0.1.9-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.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

llmshim-0.1.9-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.9.tar.gz.

File metadata

  • Download URL: llmshim-0.1.9.tar.gz
  • Upload date:
  • Size: 103.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.9.tar.gz
Algorithm Hash digest
SHA256 a1145463fc780b2235c40425b662125a08b0c0972d47e22341f3c62d9d7f0f9a
MD5 94692742162642d903299dfc0ebff3be
BLAKE2b-256 fc1702bfcf941eb334e75193377e68b1beed803f2d73d089f124a2b6305b692a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: llmshim-0.1.9-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.9-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 de9f48b347e5a282cdbdaba3eef8287a5cf346d2eebca9d08c7a8a9263ef7414
MD5 c50a274361409e047893e5758b2bca31
BLAKE2b-256 b23a4962eb2be49619fb66dd983b66fa49c8ad103c79e5678b6ef6cc772e151f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.9-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bc716a3060f5c5493faba6945f38b29653dea1c706321177669811649d787a2
MD5 18fd1054a28d104b97a24b7405224f94
BLAKE2b-256 085e5445a22eabcc34d595608f7c167bb6ca64735364f14cf6737fe1dc3b3186

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 04590259a3e640df4e24507c442e72af88dff44336dbd1ac2d58b582a04d54c5
MD5 7d4d49fbf81799246f4d89ba779da953
BLAKE2b-256 c3a05fb5d90a3fcde98006b8d8ff62318401c969ffeff45a8de586e573f937a3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.9-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd913d6b7362c1dd957b9229888c38146534f602c9e3dc122aed9116fd87b3ef
MD5 4d9e449b0dbfba3b68b6c048bd4c5121
BLAKE2b-256 defb3af1d2acedb470de8c6b6cc0ef665208737a607dc2effebf39d8697e1c90

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for llmshim-0.1.9-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4cecbe4be302ec0a348c6a043f3e7c7800702cfa5dd2d4f8592d24f1e61c79d7
MD5 4568fdfec0515a06c7ee7e9a6e4eb112
BLAKE2b-256 ac938b0803dad87110dd4d1348445124bb52f4d91c4007065d44e5638ba4354a

See more details on using hashes here.

Provenance

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