이 가이드는 Baseten chat model 시작하기에 대한 간단한 개요를 제공합니다. 모든 ChatBaseten 기능, 매개변수 및 구성에 대한 자세한 목록은 ChatBaseten API reference를 참조하세요. Baseten은 프로덕션 애플리케이션을 위해 설계된 추론을 제공합니다. Baseten Inference Stack을 기반으로 구축된 이러한 API는 주요 오픈소스 또는 커스텀 모델에 대해 엔터프라이즈급 성능과 안정성을 제공합니다: https://www.baseten.co/library/.

Overview

Details

ClassPackageLocalSerializableJS supportDownloadsVersion
ChatBasetenlangchain-basetenbetaPyPI - DownloadsPyPI - Version

Features

Tool callingStructured outputJSON modeImage inputAudio inputVideo inputToken-level streamingNative asyncToken usageLogprobs
Model API는 텍스트 입력만 지원하지만, 일부 전용 배포는 모델에 따라 이미지 및 오디오 입력을 지원합니다. 자세한 내용은 Baseten 모델 라이브러리를 확인하세요: https://www.baseten.co/library/

Setup

Baseten 모델에 액세스하려면 Baseten 계정을 생성하고 API 키를 받은 다음 langchain-baseten integration package를 설치해야 합니다. 이 페이지로 이동하여 Baseten 계정을 생성하고 API 키를 생성하세요. 완료되면 BASETEN_API_KEY environment variable을 설정하세요:

Credentials

Set API key
import getpass
import os

if "BASETEN_API_KEY" not in os.environ:
    os.environ["BASETEN_API_KEY"] = getpass.getpass("Enter your Baseten API key: ")
모델 호출에 대한 자동화된 을 활성화하려면 LangSmith API 키를 설정하세요:
Enable tracing
os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
os.environ["LANGSMITH_TRACING"] = "true"

Installation

LangChain Baseten integration은 langchain-baseten package에 있습니다:
pip install -U langchain-baseten

Instantiation

Baseten은 chat model에 액세스하는 두 가지 방법을 제공합니다:
  1. Model APIs: 최신의 가장 인기 있는 오픈소스 모델에 대한 액세스.
  2. Dedicated URLs: 전용 리소스가 있는 특정 모델 배포 사용.
두 접근 방식 모두 자동 endpoint 정규화와 함께 지원됩니다.
Initialize with model slug
from langchain_baseten import ChatBaseten

# Option 1: Use Model APIs with model slug
model = ChatBaseten(
    model="moonshotai/Kimi-K2-Instruct-0905",  # 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
)
Initialize with model URL
from langchain_baseten import ChatBaseten

# 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
)

Invocation

Basic invocation
# Use the chat model
response = model.invoke("Hello, how are you?")
print(response.content)
content="Hello! I'm doing well, thank you for asking! How about you?" additional_kwargs={} response_metadata={'finish_reason': 'stop'} id='run--908651ec-00d7-4992-a320-864397c14e37-0'
더 복잡한 대화를 위해 message object를 사용할 수도 있습니다:
messages = [
    {"role": "system", "content": "You are a poetry expert"},
    {"role": "user", "content": "Write a haiku about spring"},
]
response = model.invoke(messages)
print(response)
content='Buds yawn open wide—  \na robin stitches the hush  \nwith threads of first light.' additional_kwargs={} response_metadata={'finish_reason': 'stop'} id='run--6f7d1db7-daae-4628-a40a-2ab7323e8f15-0'
chat model invocation types, message types, content blocks에 대한 전체 가이드를 확인할 수 있습니다.

API reference

모든 ChatBaseten 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I