Skip to main content

langchain-outrun

LangChain integration for Outrun, a prepaid, OpenAI-compatible API. One Outrun key reaches GPT, Claude, Gemini, Grok, DeepSeek, GLM, Kimi, Qwen and MiniMax models.

ChatOutrun is a LangChain chat model built on langchain-openai, with the Outrun base URL and key set for you.

Install

pip install -U langchain-outrun

Create a key at https://outrun.to/key, then:

export OUTRUN_API_KEY="your-api-key"

Chat model

from langchain_outrun import ChatOutrun

model = ChatOutrun(model="gpt-5.6-terra", temperature=0)
print(model.invoke("Explain prompt caching in one sentence.").content)

Pick any model id from https://outrun.to/pricing (for example claude-haiku-5-5, gemini-3.8-flash or deepseek-v4.1-flash). The same list is available as JSON, without a key, at https://api.outrun.to/pricing.

Streaming

for chunk in model.stream("Write a haiku about rain."):
    print(chunk.text, end="", flush=True)

Token usage is included in streamed responses (usage_metadata on the last chunk).

Tool calling

from pydantic import BaseModel, Field


class GetWeather(BaseModel):
    """Get the current weather for a city."""

    city: str = Field(description="City name")


model_with_tools = model.bind_tools([GetWeather])
msg = model_with_tools.invoke("What's the weather in Paris?")
print(msg.tool_calls)

Structured output

class Answer(BaseModel):
    answer: str
    confidence: float


structured = model.with_structured_output(Answer)
print(structured.invoke("Is the sky blue? Answer briefly."))

Tool calling and structured output depend on the model you pick.

Async

ainvoke, astream and abatch work as with any LangChain chat model.

Settings

Argument Environment variable Default
api_key OUTRUN_API_KEY none (required)
base_url OUTRUN_API_BASE https://api.outrun.to/v1
model none (required)

Other ChatOpenAI arguments such as temperature, max_tokens, timeout, max_retries and default_headers work the same way.

  • Requests go to /v1/chat/completions. Pass use_responses_api=True to use /v1/responses instead (GPT models only).
  • ChatOutrun never reads OPENAI_API_KEY, so an OpenAI key is never sent to Outrun.
  • Each request carries an X-Outrun-SDK: langchain/<version> header.

Development

pip install -e . pytest pytest-asyncio pytest-socket "langchain-tests>=1,<2"
pytest tests/unit_tests --disable-socket --allow-unix-socket

tests/integration_tests call the live API (billed to your balance) and run only when OUTRUN_API_KEY is set.

License: MIT.

Metadata

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

Built distribution (wheel)

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

Total release size: 14.4 kB

Release files / langchain_outrun-0.1.0.tar.gz

Download URL langchain_outrun-0.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aa0bf47bfbe17e0f80b07e636da8185b94021f5edd1a329b6653c06d1b5bb031
BLAKE2b-256 checksum
How to use checksums
12ed469f3f00d7338657eeea089c71f13f707542adb4915512d70dd096fc9a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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

Download URL langchain_outrun-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df0c4116c98aafc58322245babd0085195b36a6310b3996e7cc91d2129403329
BLAKE2b-256 checksum
How to use checksums
cd54b1bb3ad892b5e8866b67929abd58878a6f7665ea748da41f6770e05e0011
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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