Skip to main content

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
)

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

lmux_openai-0.4.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lmux_openai-0.4.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file lmux_openai-0.4.1.tar.gz.

File metadata

  • Download URL: lmux_openai-0.4.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lmux_openai-0.4.1.tar.gz
Algorithm Hash digest
SHA256 930915b678383f2c474aa1a54ff872057de8bcdff7515c1f62726eddd8d7648a
MD5 1c9d450de5d1aded3fb798b9a1fe8f6a
BLAKE2b-256 a1a3b1bc4d5f63ab2c104e9bd58a5e217bb96e16b6ae713115740c636cf92bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_openai-0.4.1.tar.gz:

Publisher: publish.yml on cluebbehusen/lmux

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lmux_openai-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: lmux_openai-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lmux_openai-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 accb0dd851db34f54ae8f0cb96cc2ec9eabd6420aeeb03ff9c8615865fd39e0d
MD5 bf131ff940b3671b8d757a4c4e01e70b
BLAKE2b-256 4e34a1df5cfedbea5baa0d5a2bcdb0dd2ddb8fe03305741dffc275bf00bd6a08

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_openai-0.4.1-py3-none-any.whl:

Publisher: publish.yml on cluebbehusen/lmux

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