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.6

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.6
File Size Uploaded Provenance Actions
langchain_baseten-0.2.6.tar.gz 162.8 kB Without provenance Details for langchain_baseten-0.2.6.tar.gz

Built distribution (wheel)

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

Total release size: 178.8 kB

Release files / langchain_baseten-0.2.6.tar.gz

Download URL langchain_baseten-0.2.6.tar.gz
Size 162.8 kB
Tags Source
SHA-256 checksum
How to use checksums
34573de24206421d5c15c2c3eeeb8a35eef12e96e10e8cb05519ae8ae0e67377
BLAKE2b-256 checksum
How to use checksums
86183ca14466773a4a1ff9a3ec9adfeac27d813ad51987213a506539fc157faf
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.6-py3-none-any.whl

Download URL langchain_baseten-0.2.6-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81f637d1b3869f4c21dba0677e53f746e027b7629cb0733ff561e89e15e31e44
BLAKE2b-256 checksum
How to use checksums
e68866937845d77ce68f713ad5b13b033c0d3e2dc7ab1beffd2dc147e0f2cdd8
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.6

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