Skip to main content

OpenRouter LLM query client with typed requests and responses.

Project description

dr-providers

OpenRouter LLM query client with typed requests and responses. Requires Python 3.12+.

Install

pip install dr-providers

Or with uv:

uv add dr-providers

Optional CLI

pip install "dr-providers[cli]"
python -m dr_providers.cli --help

Authentication

Set your OpenRouter API key:

export OPENROUTER_API_KEY="sk-or-..."

Library usage

from dr_providers import (
    LlmRequest,
    Message,
    MessageRole,
    OpenRouterProvider,
    ProviderName,
)

with OpenRouterProvider() as provider:
    response = provider.generate(
        LlmRequest(
            provider=ProviderName.OPENROUTER,
            model="openai/gpt-4o-mini",
            messages=[
                Message(role=MessageRole.USER, content="Say hello in one word."),
            ],
        )
    )
    print(response.text)

Prompt helper

For scripts and demos, query_from_prompt builds a request from plain strings:

from dr_providers import OpenRouterProvider, ProviderName
from dr_providers.query.from_prompt import query_from_prompt

with OpenRouterProvider() as provider:
    response = query_from_prompt(
        provider,
        ProviderName.OPENROUTER,
        model="openai/gpt-4o-mini",
        prompt="Say hello in one word.",
    )

This helper is not re-exported from the top-level package.

Public API

Import stable symbols from the top-level package:

from dr_providers import LlmRequest, OpenRouterProvider, ReasoningSpec

See dr_providers.__all__ for the full list.

Development

uv sync --frozen
uv run pre-commit install
uv run pre-commit run --all-files

Run the CLI from the repo without installing:

uv run python -m dr_providers.cli --model openai/gpt-4o-mini -m "hi"

Audit corpus ground truth

This repo includes a small audit-output corpus and curated ground-truth normalization artifacts under data/audit-corpus/. Regenerate the parsed audit and analysis files with:

uv run python scripts/generate_audit_ground_truth.py \
  --corpus-dir data/audit-corpus \
  --output-dir data/audit-corpus/ground-truth

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

dr_providers-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

dr_providers-0.1.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file dr_providers-0.1.1.tar.gz.

File metadata

  • Download URL: dr_providers-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for dr_providers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 71f81597afea2f02580bd843e7769e7b41e9ae4d46d8213147c9f24f2a1f52b1
MD5 0024106007fa1ad06a83d920d3eccf7e
BLAKE2b-256 76cf14256fb6aba59954be2a6173d26b801c31f5a4856ffa4c03dfeffc8da177

See more details on using hashes here.

File details

Details for the file dr_providers-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dr_providers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae70dc3d466c9c6f4eee93d76cfe796091c74db84286b7d54254f0bd7902ba29
MD5 94ce9eef848c7cda38bfb9a070f31ec2
BLAKE2b-256 7b9439864d28f5bef0cfb75a7aebce671cc4867340a566ca720401cf5242e9df

See more details on using hashes here.

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