(beta) Agents API
Create a new agent giving it instructions, tools, description. The agent is then available to be used as a regular assistant in a conversation or as part of an agent pool from which it can be used.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.create(model="LeBaron", name="<value>", completion_args={
"response_format": {
"type": "text",
},
})
# Handle response
print(res)
models.Agent
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Retrieve a list of agent entities sorted by creation time.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.list(page=0, page_size=20)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
page |
Optional[int] |
➖ |
Page number (0-indexed) |
page_size |
Optional[int] |
➖ |
Number of agents per page |
deployment_chat |
OptionalNullable[bool] |
➖ |
N/A |
sources |
List[models.RequestSource] |
➖ |
N/A |
name |
OptionalNullable[str] |
➖ |
Filter by agent name |
search |
OptionalNullable[str] |
➖ |
Search agents by name or ID |
id |
OptionalNullable[str] |
➖ |
N/A |
metadata |
Dict[str, Any] |
➖ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
List[models.Agent]
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Given an agent, retrieve an agent entity with its attributes. The agent_version parameter can be an integer version number or a string alias.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.get(agent_id="<id>")
# Handle response
print(res)
models.Agent
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Update an agent attributes and create a new version.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.update(agent_id="<id>", completion_args={
"response_format": {
"type": "text",
},
})
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
instructions |
OptionalNullable[str] |
➖ |
Instruction prompt the model will follow during the conversation. |
tools |
List[models.UpdateAgentRequestTool] |
➖ |
List of tools which are available to the model during the conversation. |
completion_args |
Optional[models.CompletionArgs] |
➖ |
White-listed arguments from the completion API |
guardrails |
List[models.GuardrailConfig] |
➖ |
N/A |
model |
OptionalNullable[str] |
➖ |
N/A |
name |
OptionalNullable[str] |
➖ |
N/A |
description |
OptionalNullable[str] |
➖ |
N/A |
handoffs |
List[str] |
➖ |
N/A |
deployment_chat |
OptionalNullable[bool] |
➖ |
N/A |
metadata |
OptionalNullable[models.MetadataDict] |
➖ |
N/A |
version_message |
OptionalNullable[str] |
➖ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.Agent
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Delete an agent entity.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
mistral.beta.agents.delete(agent_id="<id>")
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Switch the version of an agent.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.update_version(agent_id="<id>", version=157995)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
version |
int |
✔️ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.Agent
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Retrieve all versions for a specific agent with full agent context. Supports pagination.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.list_versions(agent_id="<id>", page=0, page_size=20)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
page |
Optional[int] |
➖ |
Page number (0-indexed) |
page_size |
Optional[int] |
➖ |
Number of versions per page |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
List[models.Agent]
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Get a specific agent version by version number.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.get_version(agent_id="<id>", version="788393")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
version |
str |
✔️ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.Agent
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Create a new alias or update an existing alias to point to a specific version. Aliases are unique per agent and can be reassigned to different versions.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.create_version_alias(agent_id="<id>", alias="<value>", version=595141)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
alias |
str |
✔️ |
N/A |
version |
int |
✔️ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.AgentAliasResponse
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Retrieve all version aliases for a specific agent.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.beta.agents.list_version_aliases(agent_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
List[models.AgentAliasResponse]
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |
Delete an existing alias for an agent.
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
mistral.beta.agents.delete_version_alias(agent_id="<id>", alias="<value>")
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
N/A |
alias |
str |
✔️ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| errors.HTTPValidationError |
422 |
application/json |
| errors.SDKError |
4XX, 5XX |
*/* |