Skip to main content

Anthropic provider for lmux

Project description

lmux-anthropic

Anthropic provider for lmux. Wraps the anthropic SDK.

Supports chat completions and streaming.

Part of the lmux ecosystem: standardized interface, cost tracking on every response, and registry-based routing across providers.

Auth

Set ANTHROPIC_API_KEY in your environment. The default AnthropicEnvAuthProvider reads it automatically.

from lmux_anthropic import AnthropicProvider

provider = AnthropicProvider()

Usage

Chat

from lmux import UserMessage

response = provider.chat("claude-sonnet-4-20250514", [UserMessage(content="Hello")])
print(response.content)
print(response.cost)

Streaming

for chunk in provider.chat_stream("claude-sonnet-4-20250514", [UserMessage(content="Hello")]):
    if chunk.delta:
        print(chunk.delta, end="")

Async

All methods have async variants: achat, achat_stream.

Registry

Use with the lmux registry to route across multiple providers:

from lmux import Registry

registry = Registry()
registry.register("anthropic", provider)
response = registry.chat("anthropic/claude-sonnet-4-20250514", messages)

Provider Params

from lmux_anthropic import AnthropicParams

response = provider.chat(
    "claude-sonnet-4-20250514",
    messages,
    provider_params=AnthropicParams(inference_geo="us"),
)
Parameter Type Description
thinking dict Extended thinking configuration
metadata dict[str, str] Request metadata
top_k int Top-k sampling
service_tier "auto" | "standard_only" Service tier selection
inference_geo "us" Inference geography (affects cost)

Constructor Options

AnthropicProvider(
    auth=...,               # AuthProvider[str], default: AnthropicEnvAuthProvider()
    base_url=...,           # Optional base URL override
    timeout=...,            # Request timeout in seconds
    max_retries=...,        # Max retry attempts
    default_max_tokens=..., # Default max tokens (default: 4096)
)

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_anthropic-0.4.2.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

lmux_anthropic-0.4.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file lmux_anthropic-0.4.2.tar.gz.

File metadata

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

File hashes

Hashes for lmux_anthropic-0.4.2.tar.gz
Algorithm Hash digest
SHA256 0cc2f183c9218f74fe3a61792eb32f198cf9aa540a94de562e775d74c97d96f3
MD5 98f7bf4967e05bd4c220555b435d2b74
BLAKE2b-256 09216aac7b166c095292b84b3fd208cc13149f4135fa7099f7c60f940d75af8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_anthropic-0.4.2.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_anthropic-0.4.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for lmux_anthropic-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82349d1c5db488819da0d13cba57c41b735b33edf9470cc40457ca301671e6f9
MD5 7755c41f122750904d2374fd703af3ab
BLAKE2b-256 8d8e01a8875a87c14108c8078c72b6c10cab4ae813f35cdc509f33eafb45704e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_anthropic-0.4.2-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