CreateAgent

Updated at:

Creates an agent.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

sca:CreateAgent

none

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

BaseMeAgentId

integer

No

The workspace ID.

123456

JsonStr

string

No

The complete JSON string. For more information, see the following details.

""


Request parameters.

1. Overview

The request parameter object for agent management. It includes the basic attribute configurations and instruction type parameters of an agent.


2. Top-level fields

FieldTypeRequiredDescription
agentNameStringYesThe name of the agent.
agentDescriptionStringNoThe description of the agent.
modelTypeStringYesThe type of the large language model (LLM). For valid values, see the LLMCodeEnum enumeration.
inputTypeStringYesThe type of the analysis object. Valid values: text (text), voice (voice), and image (image).
instructionTypeStringYesThe instruction type code. For valid values, see the AgentInstructionTypeEnum enumeration in the following table.
instructionTypeParamInstructionTypeParamYesThe detailed configuration parameters for the instruction type. Pass the corresponding sub-object based on the value of instructionType.

instructionType enumeration values

codeDescriptionCorresponding Param
serviceInspectionService inspectionserviceInspectionParam
fieldKey attribute extractionfieldsParam
tagCategoryTag classificationtagCategoryParam
multiLevelTagMulti-level tag recognitiontagTreeLevelParam
customPromptCustom instructioncustomPromptParam

3. InstructionTypeParam (Instruction type parameters)

instructionTypeParam is the configuration container for various instruction types. Based on the value of instructionType, you only need to pass the corresponding sub-object. Other sub-objects can be null.

FieldTypeDescription
fieldsParamFieldsParamThe key attribute extraction configuration. Pass this parameter when instructionType is set to field.
serviceInspectionParamServiceInspectionParamThe service inspection configuration. Pass this parameter when instructionType is set to serviceInspection.
tagCategoryParamTagCategoryParamThe tag classification configuration. Pass this parameter when instructionType is set to tagCategory.
tagTreeLevelParamTagTreeLevelParamThe multi-level tag analysis configuration. Pass this parameter when instructionType is set to multiLevelTag.
customPromptParamCustomPromptParamThe custom instruction configuration. Pass this parameter when instructionType is set to customPrompt.

3.1 FieldsParam (Key attribute extraction)

FieldTypeRequiredDescription
nameDescPairListList<NameDescPair>YesThe list of key attribute dimensions to be extracted.

NameDescPair structure:

FieldTypeRequiredDescription
nameStringYesThe attribute name.
descStringYesThe attribute description.
valueStringYesThe attribute value.

3.2 ServiceInspectionParam (Service inspection)

FieldTypeRequiredDescription
sceneNameStringYesThe name of the inspection scenario.
sceneDescriptionStringYesThe description of the inspection scenario.
dimensionsList<Dimension>YesThe list of inspection dimensions, which define the specific inspection dimensions and their conditions.

Dimension structure:

FieldTypeRequiredDescription
dimensionStringYesThe dimension name. The title alias is also accepted during JSON deserialization.
descStringYesThe dimension description. The content alias is also accepted during JSON deserialization.

3.3 TagCategoryParam (Tag classification)

FieldTypeRequiredDescription
nameDescPairListList<NameDescValueListPair>YesThe list of tag classification dimensions. Each dimension can contain multiple candidate tag values.

NameDescValueListPair structure:

FieldTypeRequiredDescription
nameStringYesThe dimension or classification name.
descStringYesThe dimension description.
valueListList<String>YesThe list of candidate tag values under this dimension.

3.4 TagTreeLevelParam (Multi-level tag recognition)

FieldTypeRequiredDescription
tagIdsList<Long>YesThe list of tag IDs passed at runtime. The first ID is used as the matched starting parent tag, and matching continues from its child nodes.
tagTreeLevelsList<TagTreeLevelInfoParam>YesThe prompt configuration list for each level, arranged in hierarchical order.

TagTreeLevelInfoParam structure:

FieldTypeRequiredDescription
tagTreeIdsList<Long>YesThe list of candidate tag IDs for the current level. A value of -1 indicates all tags are selected, which means all tags at this level are matched.
promptStringYesThe analysis prompt for this level. It is concatenated with the tag data and sent to the large language model for analysis.

3.5 CustomPromptParam (Custom instruction)

FieldTypeRequiredDescription
customPromptStringYesThe custom prompt instruction content defined by the user.
nameDescPairListList<NameDescPair>NoThe list of custom fields, which are used as additional variables referenced in the prompt.

The NameDescPair structure is the same as that in Section 3.1.


4. Request example

{
  "id": 123,
  "userGroup": "default",
  "aliUid": 1000000001,
  "agentName": "Customer service inspection agent",
  "agentDescription": "Used for automatic detection of customer service dialogue quality",
  "modelType": "qwen-max",
  "inputType": "text",
  "instructionType": "serviceInspection",
  "instructionTypeParam": {
    "serviceInspectionParam": {
      "sceneName": "After-sales customer service scenario",
      "sceneDescription": "Check the service quality of after-sales customer service dialogues",
      "dimensions": [
        {
          "dimension": "Service attitude",
          "desc": "Check whether the customer service representative uses polite language",
          "includeCondition": "Includes greetings and expressions of gratitude",
          "excludeCondition": "Not excluded if there is no obvious inappropriate language"
        }
      ]
    }
  }
}

Response elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

Id of the request

106C6CA0-282D-4AF7-85F0-D2D24***

Code

string

The result code. A value of 200 indicates success, and other values indicate failure. You can use this field to determine the cause of the failure.

200

Message

string

The error message. This field is returned if an error occurs.

successful

Success

boolean

Specifies whether the call was successful. Valid values:

  • true: The call was successful.

  • false: The call failed.

true

Data

integer

The ID of the agent for the task.

12

Examples

Success response

JSON format

{
  "RequestId": "106C6CA0-282D-4AF7-85F0-D2D24***",
  "Code": "200",
  "Message": "successful",
  "Success": true,
  "Data": 12
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.