Skip to main content

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 key
  • BASETEN_BASE_URL: Custom base URL for chat model API requests; takes precedence over BASETEN_API_BASE, and defaults to the Model APIs base URL when unset
  • BASETEN_API_BASE: Legacy fallback for the base URL, used only when BASETEN_BASE_URL is 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.7

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-baseten 0.2.7
File Size Uploaded Provenance Actions
langchain_baseten-0.2.7.tar.gz 157.6 kB Without provenance Details for langchain_baseten-0.2.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-baseten 0.2.7
File Interpreter ABI Platform Actions
langchain_baseten-0.2.7-py3-none-any.whl Python 3 none any Details for langchain_baseten-0.2.7-py3-none-any.whl

Total release size: 173.9 kB

Release files / langchain_baseten-0.2.7.tar.gz

Download URL langchain_baseten-0.2.7.tar.gz
Size 157.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6bb66931829ea7565d0ec1284d0188ce646c946fb87dc48954de273d7a12dd2f
BLAKE2b-256 checksum
How to use checksums
ff1d7f69f32e7330a5ef55151ac42da66093e3f63ba9a77483212544e44ba0d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / langchain_baseten-0.2.7-py3-none-any.whl

Download URL langchain_baseten-0.2.7-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7d5d7c2f9ea3ed652773e2379c04453105bd9bd813ff9cf0d47514b856da3ab
BLAKE2b-256 checksum
How to use checksums
c148668b3d619f54db2a5d4245e7c5180139124dab2e5aad48f4b71df497680e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for langchain-baseten 0.2.7

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.

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