Skip to main content

langchain-brainiall

LangChain integration for the Brainiall LLM Gateway -- access 113+ AI models from 17 providers through a single OpenAI-compatible API.

Installation

pip install langchain-brainiall

Quick Start

from langchain_brainiall import ChatBrainiall

llm = ChatBrainiall(
    model="claude-sonnet-4-6",
    api_key="your-api-key",  # or set BRAINIALL_API_KEY env var
)

response = llm.invoke("Explain quantum computing in one sentence.")
print(response.content)

Features

  • 113+ models from 17 providers (Anthropic, DeepSeek, Meta, Qwen, Mistral, Amazon, and more)
  • OpenAI-compatible -- supports all ChatOpenAI features (streaming, tools, structured output)
  • Single API key -- one key for all models, no need to manage multiple provider accounts
  • Cost-optimized -- automatic response caching and optimized routing keep your bill low

Environment Variables

Variable Description
BRAINIALL_API_KEY API key for authentication
BRAINIALL_API_BASE Override the default API base URL

Usage Examples

Streaming

from langchain_brainiall import ChatBrainiall

llm = ChatBrainiall(model="claude-sonnet-4-6")

for chunk in llm.stream("Tell me a joke about programming"):
    print(chunk.content, end="", flush=True)

Tool Calling

from pydantic import BaseModel, Field
from langchain_brainiall import ChatBrainiall

class GetWeather(BaseModel):
    """Get current weather for a location."""
    location: str = Field(description="City name")

llm = ChatBrainiall(model="claude-sonnet-4-6")
llm_with_tools = llm.bind_tools([GetWeather])

response = llm_with_tools.invoke("What's the weather in Tokyo?")
print(response.tool_calls)

Structured Output

from pydantic import BaseModel
from langchain_brainiall import ChatBrainiall

class MovieReview(BaseModel):
    title: str
    rating: float
    summary: str

llm = ChatBrainiall(model="claude-sonnet-4-6")
structured = llm.with_structured_output(MovieReview)

review = structured.invoke("Review the movie Inception")
print(f"{review.title}: {review.rating}/10 - {review.summary}")

Multi-Model Chains

Use different models for different steps -- cheap models for drafting, powerful models for refinement:

from langchain_brainiall import ChatBrainiall

fast = ChatBrainiall(model="nova-micro", temperature=0.7)
smart = ChatBrainiall(model="claude-opus-4-6", temperature=0)

# Draft with a fast, cheap model
draft = fast.invoke("Write a short product description for wireless earbuds")

# Refine with a powerful model
final = smart.invoke(f"Improve this product description:\n{draft.content}")
print(final.content)

With LangGraph Agents

from langchain_brainiall import ChatBrainiall
from langgraph.prebuilt import create_react_agent

llm = ChatBrainiall(model="claude-sonnet-4-6")

# Define your tools
tools = [...]

agent = create_react_agent(llm, tools)
result = agent.invoke({"messages": [("human", "Help me plan a trip to Japan")]})

Embeddings

from langchain_brainiall import BrainiallEmbeddings

embeddings = BrainiallEmbeddings(
    model="bge-m3",
    api_key="your-api-key",
)

vector = embeddings.embed_query("What is machine learning?")
print(f"Dimensions: {len(vector)}")

Async Support

import asyncio
from langchain_brainiall import ChatBrainiall

async def main():
    llm = ChatBrainiall(model="claude-haiku-4-5")
    response = await llm.ainvoke("Hello!")
    print(response.content)

asyncio.run(main())

Available Models

Chat Models

Model Provider Context Window Max Output
claude-opus-4-6 Anthropic 200K 64K
claude-opus-4-6-1m Anthropic 1M 64K
claude-opus-4-5 Anthropic 200K 32K
claude-sonnet-4-6 Anthropic 200K 64K
claude-sonnet-4-6-1m Anthropic 1M 64K
claude-haiku-4-5 Anthropic 200K 16K
claude-3-opus Anthropic 200K 4K
deepseek-r1 DeepSeek 128K 64K
deepseek-v3 DeepSeek 128K 16K
llama-3.3-70b Meta 128K 4K
llama-4-scout-17b Meta 1M 16K
llama-4-maverick-17b Meta 1M 16K
qwen-3-235b Qwen 128K 16K
qwen-3-32b Qwen 128K 16K
qwen-3-8b Qwen 128K 16K
qwen-3-80b Qwen 128K 16K
mistral-large-3 Mistral 128K 16K
mistral-small-3 Mistral 128K 16K
nova-pro Amazon 300K 5K
nova-lite Amazon 300K 5K
nova-micro Amazon 128K 5K
minimax-m2 MiniMax 1M 128K
nemotron-ultra-253b NVIDIA 128K 16K
kimi-k2.5 Moonshot 128K 16K

Embedding Models

Model Dimensions Max Tokens
bge-m3 1024 8192
bge-large-en-v1.5 1024 512
cohere-embed-v3 1024 512
titan-embed-v2 1024 8192

For the complete and up-to-date model list, see the Brainiall API documentation.

Getting an API Key

  1. Visit the Brainiall dashboard
  2. Sign up for an account
  3. Generate an API key from the dashboard
  4. Set it as BRAINIALL_API_KEY environment variable

License

MIT

Metadata

Release files for langchain-brainiall 0.1.2

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-brainiall 0.1.2
File Size Uploaded Provenance
langchain_brainiall-0.1.2.tar.gz 19.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-brainiall 0.1.2
File Interpreter ABI Platform
langchain_brainiall-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 27.7 kB

Release files / langchain_brainiall-0.1.2.tar.gz

Download URL langchain_brainiall-0.1.2.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5f0a6fe00d4262084ef5bba1459f4fda61ee6c4bb0643f687c9051543f042778
BLAKE2b-256 checksum
How to use checksums
abd2009c787293d1f4d95291e4f29a4594ba2df3baf84271b716e405b6655ac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 28, 2026.

Transparency log

Release files / langchain_brainiall-0.1.2-py3-none-any.whl

Download URL langchain_brainiall-0.1.2-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4683bc8752daac6e5ef570c462399cce788a1da0ebc090a49358595631d2ae7
BLAKE2b-256 checksum
How to use checksums
1eed88ed3002a4190f5b300df717c1b00deec683643b830f5a1a6a01f21285dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 28, 2026.

Transparency log

Security for langchain-brainiall 0.1.2

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_brainiall-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 28, 2026.

Transparency log

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.

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