LLM Kit Baseten
Baseten provider for LLM Kit - Complete integration with Baseten's Model APIs and custom model deployments.
Note: This provider uses the standardized builder pattern. See the Quick Start section for the recommended usage.
Features
- Text Generation: Generate text using Baseten-hosted models or custom deployments
- Streaming: Stream responses in real-time with support for tool calls
- Tool Calling: Support for function calling with both hosted and custom models
- Text Embedding: Generate embeddings using custom model deployments
- Model APIs: Access to hosted models like DeepSeek V3, Kimi K2, and Qwen 3
- Custom Deployments: Support for dedicated model deployments with custom URLs
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= "0.1"
= "0.1"
= { = "1", = ["full"] }
Quick Start
Using the Client Builder (Recommended)
use BasetenClient;
use LanguageModel;
async
Using Settings Directly (Alternative)
use ;
use LanguageModel;
async
Configuration
Environment Variables
Set your Baseten API key as an environment variable:
Using the Client Builder
use BasetenClient;
let provider = new
.api_key
.base_url
.header
.build;
Builder Methods
The BasetenClient builder supports:
.api_key(key)- Set the API key (overridesBASETEN_API_KEYenvironment variable).base_url(url)- Set the base URL for Model APIs (default:https://inference.baseten.co/v1).model_url(url)- Set a custom model URL for dedicated deployments.name(name)- Set provider name (optional).header(key, value)- Add a single custom header.headers(map)- Add multiple custom headers.build()- Build the provider
Provider-Specific Options
Model APIs vs Custom Deployments
Baseten supports two deployment modes:
Model APIs (Hosted Models)
Use the default base URL to access Baseten's hosted models:
use BasetenClient;
let provider = new
.api_key
.build;
// Specify model ID from hosted models
let model = provider.chat_model;
Custom Model Deployments
For dedicated deployments, specify a custom model URL:
use BasetenClient;
let provider = new
.api_key
.model_url
.build;
// Model ID is optional when using custom URL
let model = provider.chat_model;
Important:
- Chat models require
/sync/v1endpoints - Embedding models require
/syncor/sync/v1endpoints
Text Embeddings
Embeddings require a custom model URL and are not available via Model APIs:
use BasetenClient;
let provider = new
.api_key
.model_url
.build;
let model = provider.text_embedding_model;
Supported Models
Model APIs (Hosted Models)
All Baseten Model API models are supported, including:
- DeepSeek:
deepseek-ai/DeepSeek-R1-0528,deepseek-ai/DeepSeek-V3-0324,deepseek-ai/DeepSeek-V3.1 - Kimi:
moonshotai/Kimi-K2-Instruct-0905 - Qwen:
Qwen/Qwen3-235B-A22B-Instruct-2507,Qwen/Qwen3-Coder-480B-A35B-Instruct - OpenAI:
openai/gpt-oss-120b - GLM:
zai-org/GLM-4.6
Custom Models
Any model deployed on Baseten can be used with a custom model URL. Supported model types:
- Chat Models - Text generation with optional tool calling
- Embedding Models - Text embeddings for similarity search
For a complete list of available hosted models, see the Baseten Model APIs documentation.
Examples
See the examples/ directory for complete examples:
chat.rs- Basic chat completion with Model APIsstream.rs- Streaming responseschat_tool_calling.rs- Tool calling with function definitionsstream_tool_calling.rs- Streaming with tool callstext_embedding.rs- Text embeddings with custom deployments
Run examples with:
Documentation
License
Apache-2.0
Contributing
Contributions are welcome! Please see the Contributing Guide for more details.