OpenAI provider for lmux
Project description
lmux-openai
OpenAI provider for lmux. Wraps the openai SDK.
Supports chat completions, streaming, embeddings, and the Responses API.
Part of the lmux ecosystem: standardized interface, cost tracking on every response, and registry-based routing across providers.
Auth
Set OPENAI_API_KEY in your environment. The default OpenAIEnvAuthProvider reads it automatically.
from lmux_openai import OpenAIProvider
provider = OpenAIProvider()
Or pass a custom auth provider:
provider = OpenAIProvider(auth=my_auth_provider)
Usage
Chat
from lmux import UserMessage
response = provider.chat("gpt-4o", [UserMessage(content="Hello")])
print(response.content)
print(response.cost)
Streaming
for chunk in provider.chat_stream("gpt-4o", [UserMessage(content="Hello")]):
if chunk.delta:
print(chunk.delta, end="")
Embeddings
response = provider.embed("text-embedding-3-small", "Hello")
print(response.embeddings)
Responses API
response = provider.create_response("gpt-4o", "Hello")
print(response.output_text)
Async
All methods have async variants: achat, achat_stream, aembed, acreate_response.
Registry
Use with the lmux registry to route across multiple providers:
from lmux import Registry
registry = Registry()
registry.register("openai", provider)
response = registry.chat("openai/gpt-4o", messages)
Provider Params
Pass OpenAI-specific parameters via provider_params:
from lmux_openai import OpenAIParams
response = provider.chat(
"o3",
messages,
provider_params=OpenAIParams(reasoning_effort="high", service_tier="flex"),
)
| Parameter | Type | Description |
|---|---|---|
service_tier |
"auto" | "default" | "flex" |
Service tier selection |
reasoning_effort |
"low" | "medium" | "high" |
Reasoning effort for o-series models |
seed |
int |
Deterministic sampling seed |
user |
str |
End-user identifier |
Constructor Options
OpenAIProvider(
auth=..., # AuthProvider[str], default: OpenAIEnvAuthProvider()
base_url=..., # Optional base URL override
timeout=..., # Request timeout in seconds
max_retries=..., # Max retry attempts
data_residency=..., # bool, default: False — apply 10% uplift for regional endpoints
)
Data Residency
OpenAI charges a 10% uplift on the gpt-5.4 family (gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.4-pro) when requests go through a regional processing (data residency) endpoint.
Data residency is selected at the transport layer (regional hostname like eu.api.openai.com), not via a per-request parameter. Set data_residency=True on the provider so lmux applies the uplift to the reported cost.
provider = OpenAIProvider(
base_url="https://eu.api.openai.com/v1",
data_residency=True,
)
The uplift is only applied to eligible models (checked via regional_uplift_applies); other models (e.g. gpt-4o, embeddings) return their standard cost even when data_residency=True.
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 Distribution
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 lmux_openai-0.5.2.tar.gz.
File metadata
- Download URL: lmux_openai-0.5.2.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c2a7485e1f5054cd28993b35e95e1bdf4e6080905e0a6b09034238bb8ac8753
|
|
| MD5 |
13a11fa2c75bc1271584c4eb4f52dd6c
|
|
| BLAKE2b-256 |
cc89ef04350479fe33dfb767f251d6cbc737c7e61f140b218f008909206fd553
|
Provenance
The following attestation bundles were made for lmux_openai-0.5.2.tar.gz:
Publisher:
publish.yml on cluebbehusen/lmux
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmux_openai-0.5.2.tar.gz -
Subject digest:
1c2a7485e1f5054cd28993b35e95e1bdf4e6080905e0a6b09034238bb8ac8753 - Sigstore transparency entry: 1319931599
- Sigstore integration time:
-
Permalink:
cluebbehusen/lmux@45b59a7cf1d81a5413a5aaadccd96b6c1d4c83ff -
Branch / Tag:
refs/tags/lmux-openai-v0.5.2 - Owner: https://github.com/cluebbehusen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@45b59a7cf1d81a5413a5aaadccd96b6c1d4c83ff -
Trigger Event:
push
-
Statement type:
File details
Details for the file lmux_openai-0.5.2-py3-none-any.whl.
File metadata
- Download URL: lmux_openai-0.5.2-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8df4ea7eddab4b206d181536b704fc26bcac3b99ecd59f06cd17725cb72f1ca
|
|
| MD5 |
8f98863a46d39a77e64b48700a9cbbcb
|
|
| BLAKE2b-256 |
7568e2284c8e3fbff2c0409d4e9eb63b2de2e3ee55c1e9221bf74f8fefe19987
|
Provenance
The following attestation bundles were made for lmux_openai-0.5.2-py3-none-any.whl:
Publisher:
publish.yml on cluebbehusen/lmux
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmux_openai-0.5.2-py3-none-any.whl -
Subject digest:
b8df4ea7eddab4b206d181536b704fc26bcac3b99ecd59f06cd17725cb72f1ca - Sigstore transparency entry: 1319931658
- Sigstore integration time:
-
Permalink:
cluebbehusen/lmux@45b59a7cf1d81a5413a5aaadccd96b6c1d4c83ff -
Branch / Tag:
refs/tags/lmux-openai-v0.5.2 - Owner: https://github.com/cluebbehusen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@45b59a7cf1d81a5413a5aaadccd96b6c1d4c83ff -
Trigger Event:
push
-
Statement type: