Skip to main content

QuickRouter for LangChain Python

langchain-quickrouter provides ChatQuickRouter, a LangChain chat model for QuickRouter's OpenAI-compatible Chat Completions endpoint. It requires Python 3.10 or later.

Install and configure

pip install langchain-quickrouter

Create an API key in the QuickRouter console and set QUICKROUTER_API_KEY in your application's environment.

Setting Default
model claude-sonnet-5-5. Pass any model ID enabled for your key.
api_key Reads QUICKROUTER_API_KEY. Strings are converted to Pydantic SecretStr.
base_url Reads QUICKROUTER_API_BASE and defaults to https://api.quickrouter.ai/v1. Keep /v1 in the API base URL.

An explicit argument takes precedence over its environment variable. If you override the base URL, use an endpoint you trust with your API key.

Invoke a model

from langchain_quickrouter import ChatQuickRouter

chat = ChatQuickRouter(max_tokens=64)
message = chat.invoke("Explain what an HTTP reverse proxy does in one sentence.")
print(message.text)

Use await chat.ainvoke(...) for asynchronous invocation.

Stream a response

from langchain_quickrouter import ChatQuickRouter

chat = ChatQuickRouter(model="deepseek-v4.1-flash", max_tokens=100)
for chunk in chat.stream("List two causes of an HTTP timeout."):
    if chunk.text:
        print(chunk.text, end="", flush=True)

Bind tools

from pydantic import BaseModel

from langchain_quickrouter import ChatQuickRouter


class Weather(BaseModel):
    """Look up weather by city."""

    city: str


chat = ChatQuickRouter()
with_tools = chat.bind_tools([Weather], tool_choice="Weather")
message = with_tools.invoke("Look up the weather in Oslo.")
print(message.tool_calls)

LangChain returns the requested tool name and arguments. Run the application tool separately when those inputs pass your application's checks. Use with_structured_output(schema, method="json_schema") on a model route that accepts native JSON Schema. Tool and structured output support vary by model and route.

Model IDs

Family Example IDs
GPT gpt-6.2-astra, gpt-6.2-sol, gpt-6.1-terra
Claude claude-opus-5-5, claude-fable-5-2, claude-sonnet-5-5, claude-haiku-5-5
Gemini gemini-4-carbon, gemini-4-hydrogen, gemini-4-neon
DeepSeek deepseek-v4.1-flash, deepseek-v4-pro
Grok grok-4.7

QUICKROUTER_MODELS exports these examples. For current model availability, supported endpoints, and rates, see QuickRouter pricing.

Metadata

Release files for langchain-quickrouter 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 langchain-quickrouter 0.1.0
File Size Uploaded Provenance Actions
langchain_quickrouter-0.1.0.tar.gz 6.4 kB Without provenance Details for langchain_quickrouter-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 11.2 kB

Release files / langchain_quickrouter-0.1.0.tar.gz

Download URL langchain_quickrouter-0.1.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c9132bbcd53ee1277c57af3581761d7c2f04fe52e42c6af27b942ce32de5c917
BLAKE2b-256 checksum
How to use checksums
a30cf645f329707f02e52161aa1afdc6dc031130e87be6c0ababeadd839ff165
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

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

Download URL langchain_quickrouter-0.1.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
518f2e2057b7bfdb9fb8d599e395fab03d50f9addfaf137cab678cce022c03b5
BLAKE2b-256 checksum
How to use checksums
5da55309350fae31e53189b9b7d553340bdaafc61bca3c61644d1c7ebb767a6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for langchain-quickrouter 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