langchain-baseten
This package contains the LangChain integration with Baseten.
Installation
pip install langchain-baseten
The embeddings functionality uses Baseten's Performance Client for optimized performance, which is automatically included as a dependency.
Chat Models
ChatBaseten class exposes chat models from Baseten.
from langchain_baseten import ChatBaseten
# Option 1: Use Model APIs with model slug
model = ChatBaseten(
model="zai-org/GLM-5.2", # Choose from available model slugs: https://docs.baseten.co/development/model-apis/overview#supported-models
api_key="your-api-key", # Or set BASETEN_API_KEY env var
)
# Option 2: Use dedicated deployments with model url
model = ChatBaseten(
model_url="https://model-<id>.api.baseten.co/environments/production/predict",
api_key="your-api-key", # Or set BASETEN_API_KEY env var
)
# Use the chat model
response = chat.invoke("Hello, how are you?")
Embeddings
BasetenEmbeddings class exposes embedding models from Baseten.
from langchain_baseten import BasetenEmbeddings
# Initialize the embeddings model
embeddings = BasetenEmbeddings(
model_url="https://model-<id>.api.baseten.co/environments/production/sync", # Your model URL
api_key="your-api-key", # Or set BASETEN_API_KEY env var
)
# Embed a single query
query_vector = embeddings.embed_query("What is the meaning of life?")
print(f"Query embedding dimension: {len(query_vector)}")
# Embed documents
vectors = embeddings.embed_documents(["Hello world", "How are you?"])
print(f"Generated {len(vectors)} embeddings of dimension {len(vectors[0])}")
Configuration
You can configure the Baseten integration using environment variables:
BASETEN_API_KEY: Your Baseten API keyBASETEN_BASE_URL: Custom base URL for chat model API requests; takes precedence overBASETEN_API_BASE, and defaults to the Model APIs base URL when unsetBASETEN_API_BASE: Legacy fallback for the base URL, used only whenBASETEN_BASE_URLis unset
Deployment Options
Chat Models:
- Model APIs: Use model slugs with shared infrastructure
- Dedicated URLs: Use specific model deployments with dedicated resources
Embeddings:
- Dedicated URLs only: Requires specific model deployment URL for Performance Client optimization
Supported Models
Baseten supports various models through their OpenAI-compatible API. You can use any model slug available in your Baseten account, or deploy custom models with dedicated URLs.
For more information about available models, visit the Baseten documentation.
Metadata
Release files for langchain-baseten 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_baseten-0.2.4.tar.gz | 159.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_baseten-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 174.9 kB
Release files / langchain_baseten-0.2.4.tar.gz
| Download URL | langchain_baseten-0.2.4.tar.gz |
|---|---|
| Size | 159.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7ad775841c0657b0a19b7723bae3db1c90cf2804544af8b2a32ed8e323b5f1c
|
|
BLAKE2b-256 checksum How to use checksums |
0bc414a7235c74ec352076ce40da32df10e1f88d160ce111138d016c82791c49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / langchain_baseten-0.2.4-py3-none-any.whl
| Download URL | langchain_baseten-0.2.4-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1e24f2659cece388afb53787d4dde29a1f529e6f5d503ccef216318054cce7d
|
|
BLAKE2b-256 checksum How to use checksums |
bec5661c5a9b89b2d434e5e77bf8c03c77ea20d720cae89ef039303e5853bd79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|