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.dev3

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.dev3
File Size Uploaded Provenance Actions
swarmauri_llm_openrouter-0.1.0.dev3.tar.gz 13.5 kB Without provenance Details for swarmauri_llm_openrouter-0.1.0.dev3.tar.gz

Built distribution (wheel)

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

Total release size: 32.4 kB

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

Download URL swarmauri_llm_openrouter-0.1.0.dev3.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d6f17c77bb4c4bc69a693d53a43acea317c85a3e445ad1042788faee099b41c4
BLAKE2b-256 checksum
How to use checksums
6b69e356bece38faed1618289022cafddaa8e7c2c8284705f99f38d0cae15bdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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.dev3-py3-none-any.whl

Download URL swarmauri_llm_openrouter-0.1.0.dev3-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ea4daf304f8e1ffe0fa6bb9fad50bbf4923bd29e5ce8122966075934df30b15
BLAKE2b-256 checksum
How to use checksums
750b121d0c6c62ef2efff7636eae4ed212231883c902ba43360bd85e1ca64f94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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.dev3

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.

Release history Release notifications | RSS feed

This release
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