LangChain integration for Brainiall LLM Gateway - 113+ AI models from 17 providers
Project description
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 -- powered by AWS Bedrock with automatic prompt caching and flex pricing
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 brainiall.com.
Getting an API Key
- Visit brainiall.com
- Sign up for an account
- Generate an API key from the dashboard
- Set it as
BRAINIALL_API_KEYenvironment variable
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_brainiall-0.1.0.tar.gz.
File metadata
- Download URL: langchain_brainiall-0.1.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48936695d2c09850ae276273c2a41facb4347bde15a3bdf7daf80f2cb231a793
|
|
| MD5 |
393ae982d576b62110f13e5adaf098ba
|
|
| BLAKE2b-256 |
4a2cee6e7f904863f4404c00a87e4c0282da29ba93edadc064fe2a2841885293
|
Provenance
The following attestation bundles were made for langchain_brainiall-0.1.0.tar.gz:
Publisher:
publish.yml on fasuizu-br/langchain-brainiall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_brainiall-0.1.0.tar.gz -
Subject digest:
48936695d2c09850ae276273c2a41facb4347bde15a3bdf7daf80f2cb231a793 - Sigstore transparency entry: 1001684651
- Sigstore integration time:
-
Permalink:
fasuizu-br/langchain-brainiall@167ccf0f9babb15cd6f67a67f0e109bfaf12c81b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fasuizu-br
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@167ccf0f9babb15cd6f67a67f0e109bfaf12c81b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file langchain_brainiall-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_brainiall-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6907725b71c1bccf4823a81fa194bd7f90cafa2647d11371854333487851db6
|
|
| MD5 |
6b4f18cceffa0eb609d018bc77a1ddcd
|
|
| BLAKE2b-256 |
946285174bde25e783e281a2a652f12f4c5e85f476973c58da28a0356a02a599
|
Provenance
The following attestation bundles were made for langchain_brainiall-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on fasuizu-br/langchain-brainiall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_brainiall-0.1.0-py3-none-any.whl -
Subject digest:
d6907725b71c1bccf4823a81fa194bd7f90cafa2647d11371854333487851db6 - Sigstore transparency entry: 1001684655
- Sigstore integration time:
-
Permalink:
fasuizu-br/langchain-brainiall@167ccf0f9babb15cd6f67a67f0e109bfaf12c81b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fasuizu-br
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@167ccf0f9babb15cd6f67a67f0e109bfaf12c81b -
Trigger Event:
workflow_dispatch
-
Statement type: