Skip to content

Latest commit

 

History

History
503 lines (338 loc) · 34.6 KB

File metadata and controls

503 lines (338 loc) · 34.6 KB

Beta.Agents

Overview

(beta) Agents API

Available Operations

create

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.

Example Usage

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)

Parameters

Parameter Type Required Description
model str ✔️ N/A
name str ✔️ N/A
instructions OptionalNullable[str] Instruction prompt the model will follow during the conversation.
tools List[models.CreateAgentRequestTool] 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
description OptionalNullable[str] N/A
handoffs List[str] 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.

Response

models.Agent

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

list

Retrieve a list of agent entities sorted by creation time.

Example Usage

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)

Parameters

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.

Response

List[models.Agent]

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get

Given an agent, retrieve an agent entity with its attributes. The agent_version parameter can be an integer version number or a string alias.

Example Usage

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)

Parameters

Parameter Type Required Description
agent_id str ✔️ N/A
agent_version OptionalNullable[models.AgentsAPIV1AgentsGetAgentVersion] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.Agent

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

update

Update an agent attributes and create a new version.

Example Usage

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)

Parameters

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.

Response

models.Agent

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

delete

Delete an agent entity.

Example Usage

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 ...

Parameters

Parameter Type Required Description
agent_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

update_version

Switch the version of an agent.

Example Usage

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)

Parameters

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.

Response

models.Agent

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

list_versions

Retrieve all versions for a specific agent with full agent context. Supports pagination.

Example Usage

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)

Parameters

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.

Response

List[models.Agent]

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get_version

Get a specific agent version by version number.

Example Usage

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)

Parameters

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.

Response

models.Agent

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

create_version_alias

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.

Example Usage

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)

Parameters

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.

Response

models.AgentAliasResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

list_version_aliases

Retrieve all version aliases for a specific agent.

Example Usage

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)

Parameters

Parameter Type Required Description
agent_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

List[models.AgentAliasResponse]

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

delete_version_alias

Delete an existing alias for an agent.

Example Usage

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 ...

Parameters

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.

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*