ListPromptTemplates - List prompt templates

Updated at:

Lists prompt templates.

Try it out

You can call this operation in OpenAPI Explorer without calculating a signature. After a successful call, OpenAPI Explorer can automatically generate SDK code examples.

Try it out

Authorization information

The following table describes the authorization information for this API operation. You can use this information in the Action element of a RAM policy statement to grant a RAM user or RAM role permission to call the operation. The columns are described as follows:

  • Action: a specific permission.

  • Access level: the access level of an action. Valid values: Write, Read, and List.

  • Resource type: the types of resources for which the action supports authorization:

    • Required resource types are marked with an asterisk (*).
    • Actions that do not support resource-level authorization use All resources.
  • Condition key: a condition key defined by the cloud service.

  • Dependent action: an additional permission required to perform the action. The caller must also have permission to perform the dependent action.

ActionAccess levelResource typeCondition keyDependent action
sfm:ListPromptTemplateslist
*All resources
*
    None
None

Endpoint

GET/{workspaceId}/promptTemplatesHTTP/1.1

Path parameters

workspaceIdstringRequired

The workspace ID.

Example: llm-xxxxxxxxxxxx

Query parameters

namestringOptional

The keyword used to search template names.

Example: Xiaohongshu
typestringOptional

The template type. Valid values: · System: system preset template · Custom: user-defined template

Example: System
maxResultsintegerOptional

The maximum number of results to return.

Example: 10
nextTokenstringOptional

The token returned by the previous request. Pass this value to retrieve the next page of results.

Example: dc270401186b433f975d7e1faaa34e0e

Response fields

object

Schema of Response

maxResultsinteger

The maximum number of results to return.

Example: 10
nextTokenstring

Used for token-based pagination.

Example: dc270401186b433f975d7e1faaa34e0e
promptTemplatesarray<object>

The list of templates.

PromptTemplatesobject
contentstring

The template content.

Example: 请写一篇小红书种草笔记,增加丰富的emoji元素,结尾作总结,并加上相关标签。主题为:${theme}
namestring

The template name.

Example: Xiaohongshu copywriting
promptTemplateIdstring

The template ID.

Example: d6935b7efbe34d11b13df9307151cf8c
typestring

The template type.

Example: "System"
variablesarray

The list of template variables.

Variablesstring

A template variable.

Example: "theme"
requestIdstring

The request ID.

Example: FE9B6CBF-47E6-5D76-9C5D-B814DD5AB071
totalCountinteger

The total number of records.

Example: 15
workspaceIdstring

The workspace ID.

Example: llm-xxxxxxxxxxxx

Response example

Sample success response

JSON format

{
  "maxResults": 10,
  "nextToken": "dc270401186b433f975d7e1faaa34e0e",
  "promptTemplates": [
    {
      "content": "请写一篇小红书种草笔记,增加丰富的emoji元素,结尾作总结,并加上相关标签。主题为:${theme}",
      "name": "小红书文案\n",
      "promptTemplateId": "d6935b7efbe34d11b13df9307151cf8c",
      "type": "System",
      "variables": [
        "theme"
      ]
    }
  ],
  "requestId": "FE9B6CBF-47E6-5D76-9C5D-B814DD5AB071",
  "totalCount": 15,
  "workspaceId": "llm-xxxxxxxxxxxx\n"
}

Error codes

HTTP status codeError codeError messageDescription
400PromptTemplate.MaxResultsInvalidInput parameter MaxResults is invalid.The maxResults parameter has an invalid format.
400PromptTemplate.NameInvalidInput parameter Name is invalid.The Name parameter has an invalid format.
400PromptTemplate.NextTokenInvalidInput parameter NextToken is invalid.The nextToken parameter is invalid.
400PromptTemplate.TypeInvalidInput parameter type is invalid.The type parameter has an invalid format.
500PromptTemplate.InternalErrorPrompt template service inner exception.An internal error occurred in the prompt template service.

For more error codes, see Error Center.