Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: add baseten as base provider with full frontend integration (#10250)
Ari Webb1addb37f7cd0
diff --git a/fern/openapi.json b/fern/openapi.jsonindex e9d0f8436..c5fc687c0 100644--- a/fern/openapi.json+++ b/fern/openapi.json@@ -28136,6 +28136,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -28148,6 +28151,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -29720,6 +29724,38 @@"required": ["tool_name", "type"],"title": "BaseToolRuleSchema"},+ "BasetenModelSettings": {+ "properties": {+ "max_output_tokens": {+ "type": "integer",+ "title": "Max Output Tokens",+ "description": "The maximum number of tokens the model can generate.",+ "default": 4096+ },+ "parallel_tool_calls": {+ "type": "boolean",+ "title": "Parallel Tool Calls",+ "description": "Whether to enable parallel tool calling.",+ "default": true+ },+ "provider_type": {+ "type": "string",+ "const": "baseten",+ "title": "Provider Type",+ "description": "The type of the provider.",+ "default": "baseten"+ },+ "temperature": {+ "type": "number",+ "title": "Temperature",+ "description": "The temperature of the model.",+ "default": 0.7+ }+ },+ "type": "object",+ "title": "BasetenModelSettings",+ "description": "Baseten model configuration (OpenAI-compatible)."+ },"BatchJob": {"properties": {"created_by_id": {@@ -32131,6 +32167,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -32143,6 +32182,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -32272,6 +32312,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -32284,6 +32327,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -32974,6 +33018,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -32986,6 +33033,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -33724,6 +33772,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -33736,6 +33787,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -34427,6 +34479,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -34439,6 +34494,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -38359,6 +38415,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -38371,6 +38430,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -42131,6 +42191,7 @@"koboldcpp","vllm","hugging-face",+ "baseten","minimax","mistral","together",@@ -49075,6 +49136,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -49087,6 +49151,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -49419,6 +49484,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -49431,6 +49499,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",@@ -50645,6 +50714,9 @@{"$ref": "#/components/schemas/BedrockModelSettings"},+ {+ "$ref": "#/components/schemas/BasetenModelSettings"+ },{"$ref": "#/components/schemas/OpenRouterModelSettings"},@@ -50657,6 +50729,7 @@"mapping": {"anthropic": "#/components/schemas/AnthropicModelSettings","azure": "#/components/schemas/AzureModelSettings",+ "baseten": "#/components/schemas/BasetenModelSettings","bedrock": "#/components/schemas/BedrockModelSettings","chatgpt_oauth": "#/components/schemas/ChatGPTOAuthModelSettings","deepseek": "#/components/schemas/DeepseekModelSettings",diff --git a/letta/llm_api/baseten_client.py b/letta/llm_api/baseten_client.pyindex 72c2a85ef..24bc4f97d 100644--- a/letta/llm_api/baseten_client.py+++ b/letta/llm_api/baseten_client.py@@ -34,7 +34,7 @@ class BasetenClient(OpenAIClient):return Falsedef is_reasoning_model(self, llm_config: LLMConfig) -> bool:- return True # hardcode for now+ return True@trace_methoddef build_request_data(@@ -88,6 +88,12 @@ class BasetenClient(OpenAIClient):if not block.get("text", "").strip():block["text"] = "."+ # Kimi K2.5 requires opt-in for reasoning via chat_template_args+ if llm_config.model == "moonshotai/Kimi-K2.5" and llm_config.enable_reasoner:+ extra = data.get("extra_body", {})+ extra["chat_template_args"] = {"enable_thinking": True}+ data["extra_body"] = extra+# Strip reasoning fields that are not in the Baseten schemaif "messages" in data:for msg in data["messages"]:diff --git a/letta/schemas/llm_config.py b/letta/schemas/llm_config.pyindex 6ec9f3c69..083c90b12 100644--- a/letta/schemas/llm_config.py+++ b/letta/schemas/llm_config.py@@ -472,6 +472,13 @@ class LLMConfig(BaseModel):temperature=self.temperature,reasoning=ChatGPTOAuthReasoning(reasoning_effort=self.reasoning_effort or "medium"),)+ elif self.model_endpoint_type == "baseten":+ from letta.schemas.model import BasetenModelSettings++ return BasetenModelSettings(+ max_output_tokens=self.max_tokens or 4096,+ temperature=self.temperature,+ )elif self.model_endpoint_type == "minimax":# MiniMax uses Anthropic-compatible APIthinking_type = "enabled" if self.enable_reasoner else "disabled"@@ -629,6 +636,12 @@ class LLMConfig(BaseModel):config.put_inner_thoughts_in_kwargs = Falsereturn config+ # Baseten models: toggle honored+ if config.model_endpoint_type == "baseten":+ config.enable_reasoner = bool(reasoning)+ config.put_inner_thoughts_in_kwargs = False+ return config+# Google Gemini 2.5 Pro and Gemini 3: not possible to disableif config.model.startswith("gemini-2.5-pro") or config.model.startswith("gemini-3"):config.put_inner_thoughts_in_kwargs = Falsediff --git a/letta/schemas/model.py b/letta/schemas/model.pyindex e5cc78067..e69ef4434 100644--- a/letta/schemas/model.py+++ b/letta/schemas/model.py@@ -42,6 +42,7 @@ class Model(LLMConfig, ModelBase):"koboldcpp","vllm","hugging-face",+ "baseten","minimax","mistral","together",@@ -531,6 +532,21 @@ class ChatGPTOAuthModelSettings(ModelSettings):}+class BasetenModelSettings(ModelSettings):+ """Baseten model configuration (OpenAI-compatible)."""++ provider_type: Literal[ProviderType.baseten] = Field(ProviderType.baseten, description="The type of the provider.")+ temperature: float = Field(0.7, description="The temperature of the model.")++ def _to_legacy_config_params(self) -> dict:+ return {+ "temperature": self.temperature,+ "max_tokens": self.max_output_tokens,+ "parallel_tool_calls": self.parallel_tool_calls,+ "strict": True,+ }++ModelSettingsUnion = Annotated[Union[OpenAIModelSettings,@@ -545,6 +561,7 @@ ModelSettingsUnion = Annotated[DeepseekModelSettings,TogetherModelSettings,BedrockModelSettings,+ BasetenModelSettings,OpenRouterModelSettings,ChatGPTOAuthModelSettings,],diff --git a/letta/schemas/providers/__init__.py b/letta/schemas/providers/__init__.pyindex 4335d1f9b..419622614 100644--- a/letta/schemas/providers/__init__.py+++ b/letta/schemas/providers/__init__.py@@ -3,6 +3,7 @@from .anthropic import AnthropicProviderfrom .azure import AzureProviderfrom .base import Provider, ProviderBase, ProviderCheck, ProviderCreate, ProviderUpdate+from .baseten import BasetenProviderfrom .bedrock import BedrockProviderfrom .cerebras import CerebrasProviderfrom .chatgpt_oauth import ChatGPTOAuthProvider@@ -26,6 +27,7 @@ from .zai import ZAICodingProvider, ZAIProvider__all__ = ["AnthropicProvider","AzureProvider",+ "BasetenProvider","BedrockProvider","CerebrasProvider","ChatGPTOAuthProvider",diff --git a/letta/schemas/providers/base.py b/letta/schemas/providers/base.pyindex 2773faada..424b910f0 100644--- a/letta/schemas/providers/base.py+++ b/letta/schemas/providers/base.py@@ -181,6 +181,7 @@ class Provider(ProviderBase):from letta.schemas.providers import (AnthropicProvider,AzureProvider,+ BasetenProvider,BedrockProvider,CerebrasProvider,ChatGPTOAuthProvider,@@ -245,6 +246,8 @@ class Provider(ProviderBase):return ZAICodingProvider(**self.model_dump(exclude_none=True))case ProviderType.lmstudio_openai:return LMStudioOpenAIProvider(**self.model_dump(exclude_none=True))+ case ProviderType.baseten:+ return BasetenProvider(**self.model_dump(exclude_none=True))case ProviderType.bedrock:return BedrockProvider(**self.model_dump(exclude_none=True))case ProviderType.minimax:diff --git a/letta/schemas/providers/baseten.py b/letta/schemas/providers/baseten.pynew file mode 100644index 000000000..a9313d27f--- /dev/null+++ b/letta/schemas/providers/baseten.py@@ -0,0 +1,94 @@+from typing import Literal++import httpx+from pydantic import Field++from letta.log import get_logger+from letta.schemas.enums import ProviderCategory, ProviderType+from letta.schemas.llm_config import LLMConfig+from letta.schemas.providers.openai import OpenAIProvider+from letta.utils import smart_urljoin++logger = get_logger(__name__)+++class BasetenProvider(OpenAIProvider):+ """Baseten serverless provider — OpenAI-compatible inference."""++ provider_type: Literal[ProviderType.baseten] = Field(ProviderType.baseten, description="The type of the provider.")+ provider_category: ProviderCategory = Field(ProviderCategory.base, description="The category of the provider (base or byok)")+ base_url: str = Field("https://inference.baseten.co/v1", description="Base URL for the Baseten serverless API.")++ async def check_api_key(self):+ """Validate API key by listing models (uses Api-Key auth)."""+ try:+ data = await self._get_models_async()+ if not data:+ raise ValueError("Baseten returned no models — check API key")+ except httpx.HTTPStatusError as e:+ from letta.errors import ErrorCode, LLMAuthenticationError++ if e.response.status_code in (401, 403):+ raise LLMAuthenticationError(message=f"Failed to authenticate with Baseten: {e}", code=ErrorCode.UNAUTHENTICATED)+ raise++ async def _get_models_async(self) -> list[dict]:+ """Fetch models from the Baseten serverless API.++ Overrides OpenAIProvider to use Api-Key auth (Baseten's /models+ endpoint does not accept Bearer tokens).+ """+ api_key = await self.api_key_enc.get_plaintext_async() if self.api_key_enc else None+ url = smart_urljoin(self.base_url, "models")+ headers = {"Content-Type": "application/json"}+ if api_key:+ headers["Authorization"] = f"Api-Key {api_key}"++ async with httpx.AsyncClient(timeout=httpx.Timeout(30.0, connect=10.0)) as client:+ response = await client.get(url, headers=headers)+ response.raise_for_status()+ data = response.json()++ return data.get("data", data)++ async def list_llm_models_async(self) -> list[LLMConfig]:+ """List models from the Baseten serverless API.++ Uses context_length and supported_features directly from the API response+ rather than litellm lookups, since Baseten provides rich model metadata.+ """+ data = await self._get_models_async()++ configs = []+ for model in data:+ model_name = model.get("id")+ if not model_name:+ continue++ # Only include models that support tool calling+ features = model.get("supported_features", [])+ if "tools" not in features:+ continue++ context_length = model.get("context_length")+ if not context_length:+ continue++ max_tokens = model.get("max_completion_tokens", 16384)++ configs.append(+ LLMConfig(+ model=model_name,+ model_endpoint_type=self.provider_type.value,+ model_endpoint=self.base_url,+ context_window=context_length,+ handle=self.get_handle(model_name),+ max_tokens=max_tokens,+ provider_name=self.name,+ provider_category=self.provider_category,+ strict=True,+ parallel_tool_calls=True,+ )+ )++ return configsdiff --git a/letta/server/server.py b/letta/server/server.pyindex dba2b73ad..3d17097f3 100644--- a/letta/server/server.py+++ b/letta/server/server.py@@ -48,6 +48,7 @@ from letta.schemas.pip_requirement import PipRequirementfrom letta.schemas.providers import (AnthropicProvider,AzureProvider,+ BasetenProvider,BedrockProvider,DeepSeekProvider,GoogleAIProvider,@@ -347,6 +348,13 @@ class SyncServer(object):api_key_enc=Secret.from_plaintext(model_settings.minimax_api_key),))+ if model_settings.baseten_api_key:+ self._enabled_providers.append(+ BasetenProvider(+ name="baseten",+ api_key_enc=Secret.from_plaintext(model_settings.baseten_api_key),+ )+ )if model_settings.zai_api_key:self._enabled_providers.append(ZAIProvider(