> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/powershell-commands/new-psuaiagent.md).

# New-PSUAiAgent

New-PSUAiAgent creates a new AI agent definition in PowerShell Universal, including its instructions, model, API key, and allowed tools.

## SYNOPSIS

Creates a new AI agent definition.

## SYNTAX

```powershell
New-PSUAiAgent -Name <String> [-Description <String>] [-Instructions <String>] [-Model <String>] [-ApiKey <Variable>] [-Provider <AiProvider>] [-Endpoint <String>] [-Tool <String[]>] [-Role <String[]>] [-AvailableInChat] [<ConnectionOptions>] [<CommonParameters>]
```

`<ConnectionOptions>`: `[-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]`.

## DESCRIPTION

Builds and persists an AI agent with model metadata, instructions, an API-key variable, and allowed tools. The provider defaults to `OpenAI`; `Anthropic` and `Custom` are also supported. A `Custom` provider requires an absolute `-Endpoint` URL. Use `-AvailableInChat` to expose the agent in admin and generated-app chat pickers.

## EXAMPLES

```powershell
New-PSUAiAgent -Name SupportAgent -Description 'Tier 1 assistant' -Instructions 'Answer from the knowledge base first.' -Model gpt-4o-mini -Tool GetUsers,GetTickets
New-PSUAiAgent -Name SupportAgent -Model gpt-4o-mini -Instructions 'Answer from the knowledge base first.' -Tool GetTickets -AvailableInChat
```

## PARAMETERS

| Parameter                | Description                                                |
| ------------------------ | ---------------------------------------------------------- |
| `-Name`                  | Required agent name.                                       |
| `-Description`           | Agent description.                                         |
| `-Instructions`          | System instructions for the agent.                         |
| `-Model`                 | Model identifier used for completions.                     |
| `-ApiKey`                | PSU variable holding the provider API key.                 |
| `-Provider`              | AI provider: `OpenAI` (default), `Anthropic`, or `Custom`. |
| `-Endpoint`              | Absolute provider URL; required when `-Provider Custom`.   |
| `-Tool`                  | Names of tools the agent may invoke (alias `-Tools`).      |
| `-Role`                  | Roles allowed to access the agent (alias `-Roles`).        |
| `-AvailableInChat`       | Makes the agent selectable in chat pickers.                |
| `-ComputerName`          | Target server URL or host name (alias `-Uri`).             |
| `-AppToken`              | Management API app token.                                  |
| `-Credential`            | Credentials for Management API Basic authentication.       |
| `-UseDefaultCredentials` | Uses current Windows credentials.                          |
| `-Integrated`            | Uses the in-process management client.                     |
| `-TrustCertificate`      | Ignores certificate validation errors.                     |
| `-Cookies`               | Reuses session authentication cookies.                     |

## INPUTS

None.

## OUTPUTS

`PowerShellUniversal.Models.Intelligence.AiAgent`.

## PERMISSIONS

The access token requires `intelligence.agents/create` to run this cmdlet remotely.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/powershell-commands/new-psuaiagent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
