Two providers ship with the framework: slack_agents.llm.anthropic (Claude) and slack_agents.llm.openai (OpenAI and compatible APIs).
Many providers expose an OpenAI-compatible API (Mistral, Groq, Together, Ollama, vLLM, etc.). Use the built-in slack_agents.llm.openai provider with base_url to point at them:
llm:
type: slack_agents.llm.openai
model: mistral-small-latest
api_key: "{MISTRAL_API_KEY}"
base_url: "https://api.mistral.ai/v1"
max_tokens: 4096
max_input_tokens: 32000
input_cost_per_million: 0.1 # optional — USD per 1M input tokens
output_cost_per_million: 0.3 # optional — USD per 1M output tokensinput_cost_per_million and output_cost_per_million are optional. When provided, they're used for cost estimation. When omitted, the built-in cost table is checked (covers native OpenAI models). If neither matches, cost estimation returns None.
LLM providers are Python modules that export a Provider class extending BaseLLMProvider.
# my_llm/gemini.py
from slack_agents.llm.base import BaseLLMProvider, LLMResponse, Message, StreamEvent
class Provider(BaseLLMProvider):
def __init__(self, model: str, api_key: str, max_tokens: int, max_input_tokens: int):
self.model = model
self.max_tokens = max_tokens
self.max_input_tokens = max_input_tokens
# Initialize your client here
def estimate_cost(self, input_tokens, output_tokens,
cache_creation_input_tokens=0, cache_read_input_tokens=0):
# Return estimated cost in USD, or None
return None
async def complete(self, messages, system_prompt="", tools=None):
# Return LLMResponse
...
async def stream(self, messages, system_prompt="", tools=None):
# Yield StreamEvent objects
...llm:
type: my_llm.gemini
model: gemini-2.0-flash
api_key: "{GEMINI_API_KEY}"
max_tokens: 4096
max_input_tokens: 200000- Internal message format is Anthropic-style (content as list of typed blocks)
- Convert to your provider's format at the boundary (see
openai.pyfor an example) stream()must yieldStreamEventobjects with types:text_delta,tool_use_start,tool_use_delta,tool_use_end,message_endestimate_cost()returns USD cost or None if unknown