Appearance
Model Providers
Elsai supports a wide range of LLM providers. The default is Amazon Bedrock, but you can switch with a single line.
Supported providers
To use model providers, make sure you install the standalone elsai-model package:
bash
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-model/ elsai-model| Provider | Connector Class | Import Path |
|---|---|---|
| Amazon Bedrock | BedrockConnector | elsai_model.bedrock |
| OpenAI | OpenAIConnector | elsai_model.openai |
| Google Gemini | GeminiService | elsai_model.gemini |
| LiteLLM | LiteLLMConnector | elsai_model.litellm |
| Azure OpenAI | AzureOpenAIConnector | elsai_model.azure_openai |
| Anthropic (Bedrock) | AnthropicBedrockConnector | elsai_model.anthropic_bedrock |
Quick switch
When an elsai_model connector object is passed to the Agent's model parameter, the framework automatically detects and wraps it in an adapter:
python
from elsai import Agent
from elsai_model.openai import OpenAIConnector
from elsai_model.gemini import GeminiService
from elsai_model.bedrock import BedrockConnector
from elsai_model.litellm import LiteLLMConnector
# OpenAI
agent = Agent(model=OpenAIConnector(model_name="gpt-4o"))
# Gemini
agent = Agent(model=GeminiService(model="gemini-2.5-flash"))
# Amazon Bedrock
agent = Agent(model=BedrockConnector(model_id="anthropic.claude-3-5-sonnet-20241022-v2:0"))
# Ollama / Local (via LiteLLM Connector)
agent = Agent(model=LiteLLMConnector(model_id="ollama/llama3", api_base="http://localhost:11434"))Common parameters
Most model classes accept these parameters:
| Parameter | Description |
|---|---|
model_id | The model identifier (required for most providers) |
temperature | Sampling temperature (0.0–1.0) |
max_tokens | Maximum tokens to generate |
streaming | Enable token streaming (default: True for most providers) |
Custom model provider
Implement the Model protocol to use any LLM:
python
from elsai.models.model import Model
from collections.abc import AsyncIterator
from typing import Any
class MyCustomModel(Model):
def converse(self, messages, system_prompt=None, tools=None, **kwargs) -> AsyncIterator[Any]:
# Call your LLM here, yield events
...
agent = Agent(model=MyCustomModel())