Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Swarmauri Logo

swarmauri_llm_openrouter

PyPI version Python versions Downloads Hits License

Use OpenRouter's unified APIs through Swarmauri's native LLM, tool-LLM, vision-language, and image-generation contracts.

Features

  • Text, reasoning, structured-output, streaming, and batch workflows.
  • Client-side Swarmauri toolkit execution through OpenRouter tool calling.
  • URL and base64 image inputs without flattening multimodal messages.
  • Dedicated image generation with binary results.
  • Provider ordering, fallback, parameter, data-collection, and ZDR controls.
  • Explicit live model discovery without constructor-time network requests.
  • Composition with swarmauri_provider_openrouter for provider configuration.
  • Persistent, injectable Swarmauri HTTP execution with conservative retries.

Installation

Install with uv:

uv add swarmauri_llm_openrouter

Install with pip:

pip install swarmauri_llm_openrouter

Usage

Chat

from swarmauri_llm_openrouter import OpenRouterModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage

conversation = Conversation()
conversation.add_message(HumanMessage(content="Explain provider routing."))
model = OpenRouterModel(
    api_key="...",
    name="openai/gpt-4o-mini",
    allowed_models=["openai/gpt-4o-mini"],
    app_name="My Swarmauri application",
)
model.predict(conversation, temperature=0.2)
print(conversation.get_last().content)

Pass an OpenRouterProvider as provider, an IHttpClient as http_client, or an IHttpRetryPolicy as retry_policy to replace the defaults. Upstream routing preferences use the separate routing argument.

Vision

from swarmauri_llm_openrouter import OpenRouterVLM

vlm = OpenRouterVLM(
    api_key="...",
    name="openai/gpt-4o-mini",
    allowed_models=["openai/**"],
)
# Add a HumanMessage whose content contains text and image_url items, then:
vlm.predict_vision(conversation)

Image generation

from swarmauri_llm_openrouter import OpenRouterImgGenModel

image_model = OpenRouterImgGenModel(
    api_key="...",
    name="openai/gpt-image-1",
    allowed_models=["openai/gpt-image-1"],
)
image_bytes = image_model.generate_image(
    "A geometric tiger rendered as stained glass",
    size="1024x1024",
    output_format="png",
)

Model discovery

from swarmauri_llm_openrouter import OpenRouterModel
from swarmauri_provider_openrouter import OpenRouterProvider

provider = OpenRouterProvider(api_key="...")
discovery = OpenRouterModel(
    provider=provider,
    allowed_models=["*"],
)
discovery.refresh_catalog()
available_models = discovery.catalog.list_model_ids(
    output_modalities="text"
)
model = OpenRouterModel(
    provider=provider,
    name="openai/gpt-4o-mini",
    allowed_models=available_models,
)

allowed_models is an inherited policy, not a provider catalog. An empty list denies every model, exact IDs allow only those models, provider patterns such as ["anthropic/**"] allow matching namespaces, and ["*"] explicitly permits all names. Model availability changes independently of package releases, so use the OpenRouter catalog when a concrete policy should mirror currently available models.

Metadata

Release files for swarmauri_llm_openrouter 0.1.0.dev4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_llm_openrouter 0.1.0.dev4
File Size Uploaded Provenance Actions
swarmauri_llm_openrouter-0.1.0.dev4.tar.gz 13.6 kB Without provenance Details for swarmauri_llm_openrouter-0.1.0.dev4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_llm_openrouter 0.1.0.dev4
File Interpreter ABI Platform Actions
swarmauri_llm_openrouter-0.1.0.dev4-py3-none-any.whl Python 3 none any Details for swarmauri_llm_openrouter-0.1.0.dev4-py3-none-any.whl

Total release size: 32.4 kB

Release files / swarmauri_llm_openrouter-0.1.0.dev4.tar.gz

Download URL swarmauri_llm_openrouter-0.1.0.dev4.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
90b70f1cc04f4656b722fbbe81ad29b8b337d317e048905b0450d94dc62dadf9
BLAKE2b-256 checksum
How to use checksums
123f50968f845c05457c40327f2c418d74d2644999033e7a8491ee198dc64b6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / swarmauri_llm_openrouter-0.1.0.dev4-py3-none-any.whl

Download URL swarmauri_llm_openrouter-0.1.0.dev4-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7501a66e9349ebdf2489fce7b130ef89ade4494a50d1aec10740595fe13f3d9e
BLAKE2b-256 checksum
How to use checksums
e6a068fee2a6474a1625a1cd6193383b4a697a227f63d04428e3e70609b7da24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for swarmauri_llm_openrouter 0.1.0.dev4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page