Skip to content

Prompt template overview

Designing prompts for different business scenarios is time-consuming and hard to maintain. Prompt templates separate fixed prompt structures from dynamic variables. Create reusable templates to centrally manage and optimize prompts. Important

This topic is applicable only to the International Edition (Singapore region).

Workflow

  1. Create a template: Save a template in the Alibaba Cloud Model Studio console or through an API to receive a unique template ID.

  2. Retrieve the template: Use the API and the template ID to retrieve the template content.

  3. Generate a prompt: Fill the template variables with your business data to produce the final prompt.

  4. Use the template: Send the generated prompt to your target model to get results.

Template types

Prompt templates fall into two categories: built-in prompt templates and custom prompt templates.

DimensionBuilt-in prompt templatesCustom prompt templates
SourceProvided by Model Studio. They cover multiple business scenarios.Create custom templates in the console or through an API.
EffectivenessOptimized and stable.Effectiveness depends on your design and testing.
UsabilityNo development needed. Call them from the console or API.Refining them may take several iterations. You need to understand prompt design principles and optimization methods, such as clear instructions, example-based guidance, and format constraints, and have basic development skills.
Common scenarios- General use cases, such as creative copywriting or office assistants. - Limited experience with prompt design.- Complex or specific business needs, such as finance risk control or medical consultation. - Strict output format requirements, such as JSON or lists.
EditableNo.Yes.

Built-in prompt templates

1. View

Go to the Prompts page to view and use the built-in prompt templates that Model Studio provides for various scenarios.

2. View and manage

View: Click View Details on a template card to view its name, content, variables, and ID.

Manage:

  • Click Copy Prompt to copy the template content.

  • Click Create Application. The template content is automatically populated in the prompt editor for the Agent Application. Use the content as-is or modify it for your needs.

  • Click Copy Template. This action creates a custom prompt template on the Prompts page, named "Built-in Prompt Template Name_Copy_Timestamp".

Custom prompt templates

1. Create

Create custom prompt templates using either the console or the API.

Console

  • Modify a built-in prompt template

    On the Built-in Prompt Template card, click Copy Template to create a copy of the custom prompt template named Built-in Prompt Template Name_Copy_Timestamp.

  • Create based on business needs

    On the Prompts page, click Create Prompt . After you complete the configuration, click Save to create the template.

API

  1. Retrieve your workspace ID. See Get APP ID and Workspace ID.

  2. Create a custom prompt template using the CreatePromptTemplate -- Create a prompt template API.

2. View and manage

After you create a custom prompt template, view it on the Prompts page.

Manage:

  • Click Modify on a template card to change its content.

  • Click Copy Prompt to copy the template content.

  • Click Create Application. The template content is automatically populated in the prompt editing box of the Agent Application. Use the content as-is or modify it for your needs.

  • Click Copy Template, and a custom prompt template is created on the current page with the name "Custom_Prompt_Template_Name_copy_timestamp".

  • Click Delete to delete the template.

Use prompt templates

Console

  1. Click Use Prompt > Create Application on a built-in or custom prompt template. The template auto-fills the prompt field.

  2. Set a model for your application and enter a question to test the prompt.

API

  1. Open the GetPromptTemplate -- Get a prompt template API reference and click Debug.

  2. In the Configure Parameters panel, enter your workspaceId and promptTemplateId.

    • workspaceId : Your workspace ID. See Get APP ID and Workspace ID.

    • promptTemplateId: The ID of a built-in or custom prompt template. Find it on the template card.

  3. Click Initiate Call to test the API online.

SDK

  1. Open the GetPromptTemplate -- Get a prompt template API reference and click Debug.

  2. In the Configure Parameters panel, enter your workspaceId and promptTemplateId. The values auto-fill in the SDK example.

    • workspaceId : Your workspace ID. See Get APP ID and Workspace ID.

    • promptTemplateId: The ID of a built-in or custom prompt template. Find it on the template card.

  3. In the debug panel, click SDK example.

  4. Run the example online, or download the full project, set your accessKeyId and accessKeySecret, and run it.

    See Get AccessKey and AgentKey.

Error codes

If a call fails, see Error messages.

FAQ

Q: What's the difference between calling the GetPromptTemplate****API and building the prompt string directly in code?

A: The GetPromptTemplate API provides these benefits:

  • Separate logic from content: Update and optimize prompts in the Model Studio console without code changes or redeployment.

  • Centralized management and collaboration: Store all prompts in one place for teams to collaborate, manage versions, and reuse templates.

  • Consistent prompts: All parts of your application use the same prompt version and structure, avoiding inconsistencies from manual updates.

Mirror of Alibaba Cloud Model Studio docs for reference and RAG. Not affiliated with Alibaba Cloud.