MistralClient.API.Beta.Agents (mistralex_ai v0.1.0)
View SourceBeta Agents API for creating and managing AI agents.
This module provides functionality to create, manage, and interact with AI agents that have specific instructions, tools, and capabilities.
Features
- Create agents with custom instructions and tools
- List and retrieve agent information
- Update agent configurations and versions
- Version management for agents
Usage
config = MistralClient.Config.new()
# Create an agent
request = %{
name: "Customer Support Agent",
model: "mistral-large-latest",
instructions: "You are a helpful customer support agent.",
tools: [
%{
type: "function",
function: %{
name: "get_order_status",
description: "Get the status of a customer order"
}
}
]
}
{:ok, agent} = MistralClient.API.Beta.Agents.create(config, request)
# List agents
{:ok, agents} = MistralClient.API.Beta.Agents.list(config)
# Get specific agent
{:ok, agent} = MistralClient.API.Beta.Agents.get(config, agent_id)
Summary
Functions
Create a new agent.
Retrieve a specific agent by ID.
List agents with optional pagination.
Update an agent's configuration.
Update an agent's active version.
Functions
@spec create(MistralClient.Config.t(), map()) :: {:ok, MistralClient.Models.Beta.Agent.t()} | {:error, term()}
Create a new agent.
Parameters
config
- Client configurationrequest
- Agent creation request with::name
- Agent name (required):model
- Model to use (required):instructions
- Instructions for the agent (optional):tools
- List of tools available to the agent (optional):description
- Agent description (optional):completion_args
- Default completion arguments (optional):handoffs
- List of agent handoff targets (optional)
Examples
request = %{
name: "Support Agent",
model: "mistral-large-latest",
instructions: "You are a helpful support agent.",
tools: [
%{
type: "function",
function: %{
name: "search_kb",
description: "Search knowledge base"
}
}
]
}
{:ok, agent} = create(config, request)
@spec get(MistralClient.Config.t(), String.t()) :: {:ok, MistralClient.Models.Beta.Agent.t()} | {:error, term()}
Retrieve a specific agent by ID.
Parameters
config
- Client configurationagent_id
- The agent ID to retrieve
Examples
{:ok, agent} = get(config, "agent_123")
@spec list(MistralClient.Config.t(), map()) :: {:ok, [MistralClient.Models.Beta.Agent.t()]} | {:error, term()}
List agents with optional pagination.
Parameters
config
- Client configurationoptions
- Optional parameters::page
- Page number (default: 0):page_size
- Number of agents per page (default: 20)
Examples
# List all agents
{:ok, agents} = list(config)
# List with pagination
{:ok, agents} = list(config, %{page: 1, page_size: 10})
@spec update(MistralClient.Config.t(), String.t(), map()) :: {:ok, MistralClient.Models.Beta.Agent.t()} | {:error, term()}
Update an agent's configuration.
This creates a new version of the agent with the updated configuration.
Parameters
config
- Client configurationagent_id
- The agent ID to updateupdates
- Map of fields to update::name
- New agent name (optional):instructions
- New instructions (optional):tools
- New tools list (optional):description
- New description (optional):completion_args
- New completion arguments (optional):handoffs
- New handoff targets (optional)
Examples
updates = %{
instructions: "Updated instructions for the agent",
tools: [new_tool]
}
{:ok, updated_agent} = update(config, agent_id, updates)
@spec update_version(MistralClient.Config.t(), String.t(), integer()) :: {:ok, MistralClient.Models.Beta.Agent.t()} | {:error, term()}
Update an agent's active version.
Parameters
config
- Client configurationagent_id
- The agent IDversion
- Version number to activate
Examples
{:ok, agent} = update_version(config, agent_id, 2)