Share via


RedTeams.CreateAsync Method

Definition

Overloads

CreateAsync(RedTeam, CancellationToken)

Creates a redteam run.

CreateAsync(BinaryContent, RequestOptions)

[Protocol Method] Creates a redteam run.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.

CreateAsync(RedTeam, CancellationToken)

Source:
RedTeams.cs

Creates a redteam run.

public virtual System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.RedTeam>> CreateAsync(Azure.AI.Projects.RedTeam redTeam, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateAsync : Azure.AI.Projects.RedTeam * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.RedTeam>>
override this.CreateAsync : Azure.AI.Projects.RedTeam * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.RedTeam>>
Public Overridable Function CreateAsync (redTeam As RedTeam, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ClientResult(Of RedTeam))

Parameters

redTeam
RedTeam

Redteam to be run.

cancellationToken
CancellationToken

The cancellation token that can be used to cancel the operation.

Returns

Exceptions

redTeam is null.

Service returned a non-success status code.

Examples

This sample shows how to call CreateAsync.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview");

RedTeam redTeam = new RedTeam(null)
{
    NumTurns = 10,
    AttackStrategies = { AttackStrategy.Easy },
    SimulationOnly = true,
    RiskCategories = { RiskCategory.HateUnfairness },
    ApplicationScenario = "qaxxxhjp",
    Tags =
    {
        ["key1287"] = "gbklekkgmxkfbhehgh"
    },
    Properties =
    {
        ["key9280"] = "fwzjtipl"
    },
};
Response<RedTeam> response = await client.CreateAsync(redTeam);

This sample shows how to call CreateAsync.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
RedTeams client = new AIProjectClient(endpoint, credential).GetRedTeamsClient(apiVersion: "2025-05-15-preview");

RedTeam redTeam = new RedTeam(null)
{
    NumTurns = 10,
    AttackStrategies = { AttackStrategy.Easy },
    SimulationOnly = true,
    RiskCategories = { RiskCategory.HateUnfairness },
};
Response<RedTeam> response = await client.CreateAsync(redTeam);

Applies to

CreateAsync(BinaryContent, RequestOptions)

Source:
RedTeams.cs

[Protocol Method] Creates a redteam run.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual System.Threading.Tasks.Task<System.ClientModel.ClientResult> CreateAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = default);
abstract member CreateAsync : System.ClientModel.BinaryContent * System.ClientModel.Primitives.RequestOptions -> System.Threading.Tasks.Task<System.ClientModel.ClientResult>
override this.CreateAsync : System.ClientModel.BinaryContent * System.ClientModel.Primitives.RequestOptions -> System.Threading.Tasks.Task<System.ClientModel.ClientResult>
Public Overridable Function CreateAsync (content As BinaryContent, Optional options As RequestOptions = Nothing) As Task(Of ClientResult)

Parameters

content
BinaryContent

The content to send as the body of the request.

options
RequestOptions

The request options, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Applies to