Skip to main content

whichmodel-haystack

PyPI Python

Haystack integration for WhichModel — cost-aware LLM model selection for your pipelines.

Installation

pip install whichmodel-haystack

Quick Start

from haystack_integrations.components.routers.whichmodel import WhichModelRouter

router = WhichModelRouter()
result = router.run(task_type="code_generation", complexity="high")

print(result["model_id"])       # e.g. "anthropic/claude-sonnet-4"
print(result["provider"])       # e.g. "anthropic"
print(result["confidence"])     # "high", "medium", or "low"

No API key required. The component calls the public WhichModel MCP server at https://whichmodel.dev/mcp.

Usage in a Pipeline

Use WhichModelRouter to dynamically select the best model before generating:

from haystack import Pipeline
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack_integrations.components.routers.whichmodel import WhichModelRouter

# Get the best model for the task
router = WhichModelRouter()
result = router.run(
    task_type="code_generation",
    complexity="high",
    estimated_input_tokens=2000,
    estimated_output_tokens=1000,
    budget_per_call=0.01,
    requirements={"tool_calling": True},
)

# Use the recommended model
print(f"Using {result['model_id']} (confidence: {result['confidence']})")
print(f"Estimated cost: ${result['recommendation']['cost_estimate_usd']:.6f}")

Parameters

Init Parameters

Parameter Type Default Description
mcp_endpoint str https://whichmodel.dev/mcp WhichModel MCP server URL
timeout float 30.0 HTTP request timeout in seconds
default_task_type str None Default task type for run()
default_complexity str "medium" Default complexity level

Run Parameters

Parameter Type Description
task_type str Task type: chat, code_generation, code_review, summarisation, translation, data_extraction, tool_calling, creative_writing, research, classification, embedding, vision, reasoning
complexity str "low", "medium", or "high"
estimated_input_tokens int Expected input size in tokens
estimated_output_tokens int Expected output size in tokens
budget_per_call float Max USD per call
requirements dict Capability requirements: tool_calling, json_output, streaming, context_window_min, providers_include, providers_exclude

Output

Key Type Description
model_id str Recommended model ID (e.g. anthropic/claude-sonnet-4)
provider str Provider name
recommendation dict Full recommendation with score, reasoning, pricing
alternative dict Alternative model from different provider/tier
budget_model dict Cheapest viable option
confidence str "high", "medium", or "low"
data_freshness str When pricing data was last updated

License

Apache-2.0

Metadata

Release files for whichmodel-haystack 0.1.0

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

Source distribution (sdist)

Source distribution for whichmodel-haystack 0.1.0
File Size Uploaded Provenance Actions
whichmodel_haystack-0.1.0.tar.gz 5.7 kB Without provenance Details for whichmodel_haystack-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 13.2 kB

Release files / whichmodel_haystack-0.1.0.tar.gz

Download URL whichmodel_haystack-0.1.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
463afff5435cb1cd8565cf260388f10615acd3080505375a50f30b43d1290a69
BLAKE2b-256 checksum
How to use checksums
1c314b50f1fc4a4a928ca234d2fa4c507321610dfdad6f8fcbea512c207e6400
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / whichmodel_haystack-0.1.0-py3-none-any.whl

Download URL whichmodel_haystack-0.1.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ccb7475454870ae1f61e0a7a814779c7679495ef0f9f73beb2db29ab451af91
BLAKE2b-256 checksum
How to use checksums
af8f0f577e46bc077bdccdfbe6d34d0096560cf1e4d10eba95a9a167cd17f0f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for whichmodel-haystack 0.1.0

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

0.1.0 This release

2 release files No provenance

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