Appearance
Model
model on an Agent block is the chat model. It is a named block, the same fields written inline, or a Bedrock model id string. Several agents can share one named block.
API keys stay in the environment. Do not write them in the file.
Installation
Install the extra that matches the provider you write.
bash
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-model/ "elsai-model[openai]==2.1.5"See YAML configuration for elsai-yaml itself.
A named model block
This is the usual form. Other blocks point at it with ${block}.
yaml
openai:
type: OpenAIModel
model_id: "{{$OPENAI_MODEL:gpt-4o-mini}}"
analyst:
type: Agent
name: Analyst
system_prompt: You are a data analyst.
model: ${openai}
tools: []python
from elsai.config import yaml_to_agent
agent = yaml_to_agent("agent.yaml", entry="analyst")
print(agent("Summarise last quarter in three bullets."))Set OPENAI_API_KEY before running.
An inline model
The same fields, written under model: on the agent. Use this when only one agent needs that model.
yaml
analyst:
type: Agent
model:
type: OpenAIModel
model_id: gpt-4o-mini
system_prompt: You are a data analyst.
tools: []A Bedrock model id
A plain string is read as an Amazon Bedrock model id, not a class name.
yaml
analyst:
type: Agent
model: anthropic.claude-3-5-sonnet-20240620-v1:0
system_prompt: You are a data analyst.
tools: []Available providers
type on a model block is one of these classes. Install the matching elsai-model extra, for example "elsai-model[openai,bedrock]==2.1.5".
| Provider | type | Docs |
|---|---|---|
| Amazon Bedrock | BedrockModel | Bedrock |
| Anthropic | AnthropicModel | Anthropic |
| Anthropic on Bedrock | AnthropicBedrockModel | Anthropic |
| OpenAI | OpenAIModel | OpenAI |
| OpenAI Responses | OpenAIResponsesModel | OpenAI Responses |
| Azure OpenAI | AzureOpenAIModel | Azure OpenAI |
| Google Gemini | GeminiModel | Gemini |
| LiteLLM | LiteLLMModel | LiteLLM |
| Mistral | MistralModel | Mistral |
| Ollama | OllamaModel | Ollama |
| llama.cpp | LlamaCppModel | llama.cpp |
| Meta Llama API | LlamaAPIModel | Llama API |
| Amazon SageMaker | SageMakerAIModel | SageMaker |
| Writer | WriterModel | Writer |
The constructor fields of that class go on the same block, for example model_id, region_name, or params. See Model Providers.