Baseten
Baseten #
Bases: OpenAI
Baseten LLM with support for both dedicated and model apis endpoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_id
|
str
|
The Baseten model ID (e.g., "12a3b4c5") or model name (e.g., "deepseek-ai/DeepSeek-V3-0324"). When using model_apis=True, only supported model slugs are allowed: - deepseek-ai/DeepSeek-R1-0528 - deepseek-ai/DeepSeek-V3-0324 - meta-llama/Llama-4-Maverick-17B-128E-Instruct - meta-llama/Llama-4-Scout-17B-16E-Instruct |
required |
model_apis
|
bool
|
If True (default), uses the model apis endpoint. If False, uses the dedicated endpoint. |
True
|
webhook_endpoint
|
Optional[str]
|
Webhook endpoint for async operations. If provided, uses async API. |
None
|
temperature
|
float
|
The temperature to use for generation |
DEFAULT_TEMPERATURE
|
max_tokens
|
int
|
The maximum number of tokens to generate |
DEFAULT_NUM_OUTPUTS
|
additional_kwargs
|
Optional[Dict[str, Any]]
|
Additional kwargs for the API |
None
|
max_retries
|
int
|
The maximum number of retries to make |
10
|
api_key
|
Optional[str]
|
The Baseten API key |
None
|
callback_manager
|
Optional[CallbackManager]
|
Callback manager for logging |
None
|
default_headers
|
Optional[Dict[str, str]]
|
Default headers for API requests |
None
|
system_prompt
|
Optional[str]
|
System prompt for chat |
None
|
messages_to_prompt
|
Optional[Callable]
|
Function to format messages to prompt |
None
|
completion_to_prompt
|
Optional[Callable]
|
Function to format completion prompt |
None
|
pydantic_program_mode
|
PydanticProgramMode
|
Mode for Pydantic handling |
DEFAULT
|
output_parser
|
Optional[BaseOutputParser]
|
Parser for model outputs |
None
|
Examples:
pip install llama-index-llms-baseten
from llama_index.llms.baseten import Baseten
# Using model apis endpoint (default behavior)
llm = Baseten(
model_id="deepseek-ai/DeepSeek-V3-0324",
api_key="YOUR_API_KEY",
model_apis=True, # Default
)
response = llm.complete("Hello, world!")
# Using dedicated endpoint (for custom deployed models)
llm = Baseten(
model_id="YOUR_MODEL_ID",
api_key="YOUR_API_KEY",
model_apis=False,
)
response = llm.complete("Hello, world!")
# Asynchronous usage with webhook (dedicated endpoint only)
async_llm = Baseten(
model_id="YOUR_MODEL_ID",
api_key="YOUR_API_KEY",
model_apis=False, # Required for async operations
webhook_endpoint="https://your-webhook.com/baseten-callback"
)
response = await async_llm.acomplete("Hello, world!")
request_id = response.text # Track this ID for webhook response
Source code in llama-index-integrations/llms/llama-index-llms-baseten/llama_index/llms/baseten/base.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
class_name
classmethod
#
class_name() -> str
Get class name.
Source code in llama-index-integrations/llms/llama-index-llms-baseten/llama_index/llms/baseten/base.py
148 149 150 151 |
|
acomplete
async
#
acomplete(prompt: str, **kwargs: Any) -> CompletionResponse
Async completion - requires webhook_endpoint for async API.
Source code in llama-index-integrations/llms/llama-index-llms-baseten/llama_index/llms/baseten/base.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|