> For the complete documentation index, see [llms.txt](https://ultrasafe.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ultrasafe.gitbook.io/docs/integrations.md).

# Agents

### What are AI agents?[​](https://docs.mistral.ai/capabilities/agents/#what-are-ai-agents)

AI agents are autonomous systems driven by large language models (LLMs) that, when provided with high-level directives, can independently plan, utilize tools, execute multi-step processes, and take actions to accomplish defined objectives. These agents employ advanced natural language processing (NLP) techniques to interpret and perform complex tasks with efficiency. Additionally, they possess the capability to collaborate with other agents, enabling them to achieve more intricate and sophisticated outcomes.

### Creating Agents[​](https://docs.mistral.ai/capabilities/agents/#creating-agents)

We provide two primary methods for creating agents:

* La Plateforme [Agent builder](https://console.mistral.ai/build/agents/new): Users can use a user-friendly interface provided on La Plateforme to create and configure their agents.
* [Agent API](https://docs.mistral.ai/capabilities/agents/#the-agents-api): For developers, we offer the Agents API as a programmatic means to use agents. This method is ideal for developers who need to integrate agent creation into their existing workflows or applications.

### La Plateforme agent builder[​](https://docs.mistral.ai/capabilities/agents/#la-plateforme-agent-builder)

To start building your own agent, visit [https://console.Ultrasafe.ai/build/agents/new](https://console.mistral.ai/build/agents/new).

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdT0MKptJ9vCU38D0pW31w3dpnszwyP1A0ybmipkDNi5IzDTacvznkOjYGWbsKapJcPJQRgW_vlnbAKvwzWM0gUKyeHR-F-LtgFgaHIp3tdkv-ekLA7TUS5z1GQ8FnnzylrWeOVw7BNaQOIOvDsT8crFQ?key=rJldTYnqSOCJnhAWBD4HIg" alt=""><figcaption></figcaption></figure></div>

Here are the available options for customizing your agent:

* Model: The specific model you would like the agent to use. Default is "Ultrasafe Large 2" (Ultrasafe-large-2407). The other model choices are "Ultrasafe Nemo" (open-Ultrasafe-nemo), "Codestral" (codestral-2405), and your fine-tuned models.
* Temperature: What sampling temperature to use, between 0.0 and 1.0. Higher values will make the output more random, while lower values will make it more focused and deterministic.
* Instructions (optional): Instructions allows you to enforce a model behavior through all conversations and messages.
* Demonstrations (optional): Few-shot learning examples can be added to help guide the agent to understand the specific behavior you want it to exhibit. You can show the model some examples of input and output to improve performance.
* Deploy: Once deployed, you will be able to call the Agent via the API with the agent\_id, but you can also toggle the option to chat with the corresponding Agent on [Le Chat](https://chat.mistral.ai/chat).

### The Agent API[​](https://docs.mistral.ai/capabilities/agents/#the-agent-api)

#### Create an agent[​](https://docs.mistral.ai/capabilities/agents/#create-an-agent)

Coming soon

### Use an agent[​](https://docs.mistral.ai/capabilities/agents/#use-an-agent)

```python
import os
from Ultrasafeai import Ultrasafe

api_key = os.environ["Ultrasafe_API_KEY"]
client = Ultrasafe(api_key=api_key)

chat_response = client.agents.complete(
   agent_id="ag:3996db2b:20240805:french-agent:a8997aab",
   messages=[
       {
           "role": "user",
           "content": "What is the best French cheese?",
       },
   ],

```

### Use Cases[​](https://docs.mistral.ai/capabilities/agents/#use-cases)

#### Use case 1: French agent

You can create an agent that only speaks French. You'll need to set up the agent with specific instructions and use few-shot learning to ensure it understands the requirement to communicate solely in French.

Here is an example of how you can create this agent with the La Plateforme [agent builder](https://console.mistral.ai/build/agents/new).

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfXBS9t7lx-al_6j8wjKUkKYee2oeBrSt0Sw1nsL9P6bI2DlqT3ITNC9CZWwVR-AlOWEDz8XfvPOXaZ0kd4HX8BXV3D8giuEQL6MLj1MPDbtY833qClG_LkvIdHrAQJ42Sc4gyjf_fiHqvD-Qv8Nk0ERwY?key=rJldTYnqSOCJnhAWBD4HIg" alt=""><figcaption></figcaption></figure></div>

#### Use case 2: Python agent

You can create an agent that outputs only Python code without any explanations. This is useful when you need to generate code snippets that can be easily copied and pasted, without the additional explanatory text that our model typically provides.

Here is an example of how you can create this agent with using the La Plateforme [agent builder](https://console.mistral.ai/build/agents/new).

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeynMqcnvW_U-hVqUrnk60CaldCWwAOfHWsA6Ei7Xzv5RAodhqmMLlm6TukoQ4_q9Sf4XO8yV-glGWzpCPgE0kyiW4QHh3vuDCMrVljrUPzeLbFm_4e61D9chPZz-F-IhbygJHEJTzU2RZs8iPOeI1QqPY?key=rJldTYnqSOCJnhAWBD4HIg" alt=""><figcaption></figcaption></figure></div>

#### Use case 3: Python agent workflow

You can use the Python agent we created in use case 2 in an assistant coding workflow. For example, here is a very simple Python agent workflow with the following steps:

1. User Query:

The process starts when the user submits a query or request to the Python agent.

2. Code and Test Case Generation:

The agent interprets the user's query and generates the corresponding Python code. Alongside the code, the agent creates a test case to verify the functionality of the generated code.

3. Execution and Validation:

The agent attempts to run the generated code to ensure it executes without errors. The agent then runs the test case to confirm that the code produces the correct output.

4. Retry Mechanism:

If the code fails to run or the test case does not pass, the agent initiates a retry. It regenerates the code and test case, addressing any issues identified during the previous attempt.

5. Result Output:

Once the code runs successfully and passes the test case, the agent delivers the result to the user.

Check out this [example notebook](https://github.com/mistralai/cookbook/blob/main/mistral/agents/simple_Python_agent_workflow.ipynb) for details.

#### Use case 4: Data analytical multi-agent workflow

You can also leverage multiple agents in a workflow. Here is an example:

1. Data Analysis Planning:

The planning agent writes a comprehensive data analysis plan, outlining the steps required to analyze the data.

2. Code Generation and Execution:

For each step in the analysis plan, the Python agent generates the corresponding code. The Python agent then executes the generated code to perform the specified analysis.

3. Analysis Report Summarization:

Based on the results of the executed code, the summarization agent writes an analysis report. The report summarizes the findings and insights derived from the data analysis.

Check out this [example notebook](https://github.com/mistralai/cookbook/blob/main/mistral/agents/analytical_agent_workflow.ipynb) for details.

#### Use case 5: Role-playing Conversation agent

You can also create role-playing conversation agents. For instance, in this [example](https://github.com/mistralai/cookbook/blob/main/mistral/agents/conversation_agent.ipynb), the role-playing conversation workflow generates an entertaining and humorous exchange between two agents mimicking the styles of two stand-up comedians Ali Wong and Jimmy Yang, incorporating jokes and comedic elements to enhance the conversation.
