Skip to main content

Lightweight Python SDK for the LLMWise multi-model API (chat, compare, blend, judge, failover).

Project description

LLMWise Python SDK

Lightweight Python client for the LLMWise multi-model API:

  • Chat (single model + Auto routing)
  • Failover routing (primary + fallback chain)
  • Compare (run 2+ models in parallel)
  • Blend (synthesize answers from multiple models, supports MoA / Self-MoA)
  • Judge (model-vs-model evaluation)
  • Full API coverage for conversations, history, credits, usage, keys, memory, optimization, and settings.

This SDK is intentionally small: it depends only on httpx.

Install

pip install llmwise

Quickstart (Chat)

from llmwise import LLMWise

client = LLMWise("mm_sk_...")

resp = client.chat(
    model="auto",
    messages=[{"role": "user", "content": "Write a haiku about rate limits."}],
    stream=False,
)

print(resp["content"])

Streaming (Chat)

from llmwise import LLMWise

client = LLMWise("mm_sk_...")

for event in client.chat_stream(
    model="claude-sonnet-4.5",
    messages=[{"role": "user", "content": "Explain recursion to a 10-year-old."}],
):
    if event.get("event") == "done":
        print(f"\n\ncharged={event.get('credits_charged')} remaining={event.get('credits_remaining')}")
        break
    delta = event.get("delta")
    if delta:
        print(delta, end="", flush=True)

Failover (Chat + Routing)

from llmwise import LLMWise

client = LLMWise("mm_sk_...")

for event in client.chat_stream(
    model="claude-sonnet-4.5",
    routing={"fallback": ["gpt-5.2", "gemini-3-flash"], "strategy": "rate-limit"},
    messages=[{"role": "user", "content": "Summarize this in 3 bullets: ..."}],
):
    # route/trace events are emitted when failover triggers
    if event.get("event") in {"route", "trace"}:
        continue
    if event.get("event") == "done":
        break
    if event.get("delta"):
        print(event["delta"], end="", flush=True)

Compare (2+ models)

from llmwise import LLMWise

client = LLMWise("mm_sk_...")

events = client.compare_stream(
    models=["gpt-5.2", "claude-sonnet-4.5", "gemini-3-flash"],
    messages=[{"role": "user", "content": "Draft a short product description for a credit-based LLM gateway."}],
)

by_model = {}
for ev in events:
    if ev.get("event") == "summary":
        print("summary:", ev)
    if ev.get("event") == "done":
        break
    if ev.get("delta"):
        by_model.setdefault(ev["model"], "")
        by_model[ev["model"]] += ev["delta"]

Configure

Environment variables:

  • LLMWISE_API_KEY
  • LLMWISE_BASE_URL (default: https://llmwise.ai/api/v1)

Notes

  • Authentication uses Authorization: Bearer <mm_sk_...> (or a Clerk JWT).
  • Streaming uses Server-Sent Events (SSE) and yields parsed JSON dictionaries.

Additional API Helpers

  • conversations(), create_conversation(), update_conversation(), delete_conversation()
  • history(), get_history_detail()
  • credits_wallet(), credits_transactions(), credits_packs(), credits_purchase(), credits_confirm_checkout(), credits_update_auto_topup(), credits_balance()
  • usage_summary(), usage_recent()
  • keys_info(), generate_api_key(), revoke_api_key()
  • memory_list(), memory_search(), memory_delete(), memory_clear()
  • optimization_* helpers, including policy/report/evaluate/replay/test suites/regression schedules
  • settings_* helpers, including provider keys, privacy, and copilot state/ask endpoints

Additional API Helper Examples

Dashboard/API Health Check (Read-only)

from llmwise import LLMWise

client = LLMWise()

print("models:", len(client.models()))
print("balance:", client.credits_balance())
print("usage:", client.usage_summary(days=7))
print("conversations:", client.conversations(limit=5))

Conversation Lifecycle

from llmwise import LLMWise

client = LLMWise()

convo = client.create_conversation()
convo_id = convo["id"]
client.update_conversation(convo_id, title="API smoke room")
history = client.history(limit=10)
client.delete_conversation(convo_id)

print("history entries:", history.get("total", 0))

Credits & Cost

from llmwise import LLMWise

client = LLMWise()

print("wallet:", client.credits_wallet())
print("recent usage:", client.usage_recent(days=7, limit=5))
print("packs:", client.credits_packs())

Settings and Optimization

from llmwise import LLMWise

client = LLMWise()

print("copilot:", client.settings_copilot_state())
print("privacy:", client.settings_privacy())
print("policy:", client.optimization_policy())
print("report:", client.optimization_report(days=1))

Smoke Script

Run all read-only SDK health checks:

LLMWISE_API_KEY=mm_sk_... python examples/smoke.py

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

llmwise-0.1.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

llmwise-0.1.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file llmwise-0.1.2.tar.gz.

File metadata

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

File hashes

Hashes for llmwise-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7b4873a05d77b321c23f32174d40244c4e0a89cb7cb2f7230002e96ea503f828
MD5 2b0d6bee2a24d9157eb96a73010c1d43
BLAKE2b-256 2eccec7cf4a662c350bc41fd3f6eed6c3b315e62c57a66b44358e369065ab371

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmwise-0.1.2.tar.gz:

Publisher: publish-pypi.yml on LLMWise-AI/llmwise-python-sdk

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

File details

Details for the file llmwise-0.1.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for llmwise-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c17c5eddf31ae6b55081c1e64f2563ff2f7080e52c3c92b439b72815b18415f1
MD5 1cd356c427727356b6994366ce6fb6d0
BLAKE2b-256 c38f0179aa257c8801b9b8579433eaa0bfdd815859d62160bacd66150d8961b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmwise-0.1.2-py3-none-any.whl:

Publisher: publish-pypi.yml on LLMWise-AI/llmwise-python-sdk

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