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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_baseten-0.2.3.tar.gz (156.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_baseten-0.2.3-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_baseten-0.2.3.tar.gz.

File metadata

  • Download URL: langchain_baseten-0.2.3.tar.gz
  • Upload date:
  • Size: 156.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for langchain_baseten-0.2.3.tar.gz
Algorithm Hash digest
SHA256 3d15f3ba78e294ddc027c45aa841683418d52c3f1e59a08bde0b33e45ab2cdc4
MD5 86bc8b67ec10282d99bb8817ea42616b
BLAKE2b-256 b06be18045117bd59d055bcb5b9586009dfc6d03974511ae567f2133c25d92c1

See more details on using hashes here.

File details

Details for the file langchain_baseten-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_baseten-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7bc64ed9f08bf5d0ccbb0d89ccb6c552241fc478ed35e701d07dec836936dcbc
MD5 462e79eff87e166e15b76de33ac40a6b
BLAKE2b-256 129ba794392ec17b4e4f96d25e4b1f003408bc42d447e69562b3f800d15ac107

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page