> For the complete documentation index, see [llms.txt](https://docs.uncodie.com/1.0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uncodie.com/1.0/agentbase/api/agent.md).

# Agent

Structured agent calling

## Local IDE Access

Most model providers grant access to a terminal or console to your agents while this could be a desired behavior its token expensive and time consuming compared with modern APIs, AgentBase grants access to your own IDE in order to cache, test and deploy the generated code for your prompts.

## Usage

The `/agent` endpoint is used to send messages or commands to your agents. This is particularly useful for triggering Natural Language Tasks or tools from different models.

This endpoint will not call a function in your API normally, calling Agent will result in token consumption for your selected model.

The `Return` in the endopoint can be passed around through all the agents sequence you desing, extending, calling new tools or calling internal endpoints as assistants.

<mark style="color:green;">`POST`</mark> `/agent`

Create a new function, installs dependencies, builds tests and executes the resulting code

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

<table><thead><tr><th width="223">Name</th><th width="97">Type</th><th width="102" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>agent</code></td><td>string</td><td>true</td><td>Name of the agent</td></tr><tr><td><code>prompt</code></td><td>string</td><td>true</td><td>The instructions for AgentBase to transform in to code</td></tr><tr><td><code>data</code></td><td>object</td><td>false</td><td>The data example or parameters for your function to work</td></tr><tr><td><code>tools</code></td><td>array</td><td>false</td><td>List of internal functions to call whenever the agent decides is necessary. A default list is passed to all agents additional to your own.</td></tr><tr><td><code>return</code></td><td>object</td><td>false</td><td>The data example of your expected return</td></tr><tr><td><code>model</code></td><td>string</td><td>false</td><td>The model to run for your prompt</td></tr><tr><td><code>errors</code></td><td>array</td><td>false</td><td>List or possible errors your function needs to catch</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "session_id": 1,
  "state": {
    "message" : "message example"
  },
  "status" : {
    "code" : 1,
    "status" : "waiting for user",
    "error": null
  },
  "error": null
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}
