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:
- Finds the
llmshimbinary (bundled, on PATH, or in repo) - Starts the proxy on a random localhost port
- Routes your request through it
- Server stops automatically when Python exits
No Docker, no background services, no manual server management.
Supported Models
| Provider | Models |
|---|---|
| OpenAI | gpt-5.4, gpt-5.4-mini, gpt-5.4-nano |
| 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.20-multi-agent-beta-0309, grok-4.20-beta-0309-reasoning, grok-4.20-beta-0309-non-reasoning, grok-4-1-fast-reasoning, grok-4-1-fast-non-reasoning |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmshim-0.1.15.tar.gz.
File metadata
- Download URL: llmshim-0.1.15.tar.gz
- Upload date:
- Size: 106.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b639e842f4e29f49146e0fac3b5aa0b99f76cf1c11c28d62b2e5988db8522b55
|
|
| MD5 |
92b3013952d9770f075b1dae6d16502b
|
|
| BLAKE2b-256 |
738cf7cccc5d0dc1f200a03a5a94853a570a63a8799a57579ea46b28454aab7b
|
Provenance
The following attestation bundles were made for llmshim-0.1.15.tar.gz:
Publisher:
release.yml on sanjay920/llmshim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmshim-0.1.15.tar.gz -
Subject digest:
b639e842f4e29f49146e0fac3b5aa0b99f76cf1c11c28d62b2e5988db8522b55 - Sigstore transparency entry: 1128076824
- Sigstore integration time:
-
Permalink:
sanjay920/llmshim@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/sanjay920
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Trigger Event:
push
-
Statement type:
File details
Details for the file llmshim-0.1.15-py3-none-win_amd64.whl.
File metadata
- Download URL: llmshim-0.1.15-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4b68038667dec2f28cf4ada39b7835b09975d2bd5a7d7a74bb4e7431dd2578d
|
|
| MD5 |
33129e418e1f93bcc29ff5b22a1d3361
|
|
| BLAKE2b-256 |
e28c2d800ab6bcc0b9bd0529703969f3e26e9ebd6259de7ea278093b1fe4c2aa
|
Provenance
The following attestation bundles were made for llmshim-0.1.15-py3-none-win_amd64.whl:
Publisher:
release.yml on sanjay920/llmshim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmshim-0.1.15-py3-none-win_amd64.whl -
Subject digest:
f4b68038667dec2f28cf4ada39b7835b09975d2bd5a7d7a74bb4e7431dd2578d - Sigstore transparency entry: 1128077222
- Sigstore integration time:
-
Permalink:
sanjay920/llmshim@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/sanjay920
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Trigger Event:
push
-
Statement type:
File details
Details for the file llmshim-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: llmshim-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
064d7c78a0a6705f0b8d74f869bbcbd2e4b30cce28b692dc09399e25e0bf0018
|
|
| MD5 |
f16854dc33ddfeeb0433c4ff732b3fe5
|
|
| BLAKE2b-256 |
0be0438ed655ebbec1d66b5d4ad9f1478a33809015c8d50dc8b4f7a339cd9da6
|
Provenance
The following attestation bundles were made for llmshim-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on sanjay920/llmshim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmshim-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
064d7c78a0a6705f0b8d74f869bbcbd2e4b30cce28b692dc09399e25e0bf0018 - Sigstore transparency entry: 1128076876
- Sigstore integration time:
-
Permalink:
sanjay920/llmshim@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/sanjay920
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Trigger Event:
push
-
Statement type:
File details
Details for the file llmshim-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: llmshim-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.1 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f390d427a9efa8e547d20f1decd5d0bb99dcabd9e528b02c7e94a076bc734ac7
|
|
| MD5 |
e62dbb92c93e649abf6defbbd00277d3
|
|
| BLAKE2b-256 |
19d681a540a927ed92969e8b6063e5375c434bbb782925de04638bfb844cec43
|
Provenance
The following attestation bundles were made for llmshim-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on sanjay920/llmshim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmshim-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
f390d427a9efa8e547d20f1decd5d0bb99dcabd9e528b02c7e94a076bc734ac7 - Sigstore transparency entry: 1128076967
- Sigstore integration time:
-
Permalink:
sanjay920/llmshim@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/sanjay920
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Trigger Event:
push
-
Statement type:
File details
Details for the file llmshim-0.1.15-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: llmshim-0.1.15-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.0 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4b07d841ba4ce49826b72d591d8a504d7dd97de8ed5f75e4732d5458ce4de36
|
|
| MD5 |
0a0cad8fed5af390c5c9bb320124867b
|
|
| BLAKE2b-256 |
8e150b261f318dcdaed8a2a39ac508327eee8b24dd7a3bab69bd5e242d78d5fc
|
Provenance
The following attestation bundles were made for llmshim-0.1.15-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on sanjay920/llmshim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmshim-0.1.15-py3-none-macosx_11_0_arm64.whl -
Subject digest:
d4b07d841ba4ce49826b72d591d8a504d7dd97de8ed5f75e4732d5458ce4de36 - Sigstore transparency entry: 1128077137
- Sigstore integration time:
-
Permalink:
sanjay920/llmshim@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/sanjay920
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Trigger Event:
push
-
Statement type:
File details
Details for the file llmshim-0.1.15-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: llmshim-0.1.15-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc0a09762363954509ad57b3145184a85b2d7e28b271a26cfead5631ed78b7c8
|
|
| MD5 |
235d9176ffdec56e16092291a377adce
|
|
| BLAKE2b-256 |
82f2c6d620e4e7ef3fbfacc69b6071979e45ee2d247402b1b0e2896e54528b0e
|
Provenance
The following attestation bundles were made for llmshim-0.1.15-py3-none-macosx_10_12_x86_64.whl:
Publisher:
release.yml on sanjay920/llmshim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmshim-0.1.15-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
fc0a09762363954509ad57b3145184a85b2d7e28b271a26cfead5631ed78b7c8 - Sigstore transparency entry: 1128077058
- Sigstore integration time:
-
Permalink:
sanjay920/llmshim@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/sanjay920
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@dfc59779d2ef6b83e0d8d898109653d407856c8d -
Trigger Event:
push
-
Statement type: