Prompt template overview

更新时间:
复制 MD 格式

Prompt templates let you separate the fixed structure of a prompt from its dynamic variables, creating reusable templates for unified management, optimization, and efficient prompt generation.

Important

This topic is applicable only to the Chinese Mainland Edition (Beijing region).

Workflow

  1. Create a template: Create and save a template in the Model Studio console or by using an API to obtain 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 in the template variables with your business data to generate the final prompt.

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

Template types

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

Dimension

Built-in

Custom

Source

Provided by Model Studio to cover a wide range of business scenarios.

Users create them in the console or by using an API.

Effectiveness

Pre-optimized to ensure stable performance.

Effectiveness depends on the quality of your design and testing.

Usability

Ready to use without additional development. You can call them directly from the console or by using an API.

May require multiple iterations of refinement. You must be familiar with prompt design principles and optimization methods, such as providing clear instructions, few-shot examples, and format constraints. Basic development and technical skills are also required.

Common scenarios

  • General-purpose scenarios, such as creative copywriting and office assistance.

  • Users with limited experience in prompt design.

  • Complex or specific business scenarios, such as financial risk assessment or medical consulting.

  • Scenarios with strict output format requirements, such as JSON or lists.

Editable

No.

Yes. You can modify templates based on your needs.

Built-in prompt templates

1. View templates

On the Prompts page, you can view and use the built-in prompt templates that Model Studio provides for different scenarios.

Each prompt template is shown on a card that displays a content preview and its template ID. The card includes buttons for View Details, Copy prompt, and more actions (...).

2. View and manage templates

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

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. You can use the content as-is or modify it based on your business scenario.

    The populated prompt contains the custom variables ${number} and ${content} for generating content in the Xiaohongshu style.

  • Click Call API to view code examples for calling the prompt template. These are core code examples and cannot be run directly. For a complete code example, see the SDK example in GetPromptTemplate - Get a prompt template.

  • Click Copy Template to create a custom prompt template on the Prompts page. The new template is named "Built-in Prompt Template Name_Copy_Timestamp".

    The copied template card displays a preview of the template content and the template ID (click the icon on the right to copy it). The bottom of the card provides buttons for Edit, Copy prompt, and more actions.

Custom prompt templates

1. Create a template

You can create custom prompt templates in the console or by using an API.

Console

  • Modify a built-in prompt template

    On a built-in prompt template card, click Copy Template to create a copy named "Built-in Prompt Template Name_Copy_Timestamp".

  • Create a template based on your business needs

    On the Prompts page, click Create Prompt. After you complete the configuration, click Save to create the template. For more information, see Custom prompt templates. On the prompt template management page, you can find existing templates by using the type filters (All, Text Generation, and Image Generation) or the search bar. Click + Create Prompt in the upper-right corner to create a new prompt template. Created templates are displayed as cards that show the template title, a content preview, and the template ID, with options to Edit and Copy prompt.

API

  1. Get your workspace ID: For more information, see Get an app ID and a workspace ID.

  2. Create a custom prompt template: Use the CreatePromptTemplate API operation.

2. View and manage templates

View: After you create a custom prompt template, you can 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 editor for the Agent Application. You can use the content as-is or modify it based on your business scenario.

  • Click Call API to view code examples for calling the template. These are core code examples and cannot be run directly. For a complete code example, see the SDK example in GetPromptTemplate - Get a prompt template.

  • Click Copy Template to create a copy on the current page named "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 card. The template content automatically populates the prompt field of the Agent Application.

    Template variables, such as ${name}, are visible in the prompt input box. A character counter in the lower-right corner shows the current count, with a maximum of 6,144 characters.

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

    On the left side of the model debugging page, select a model, such as Qwen-Plus-Latest 128K, and write system instructions in the prompt area. On the right side, enter a test question in the user input area and click Run. The model's response and token statistics for the input and output are displayed below.

API

  1. Open the GetPromptTemplate API reference and click Debug.

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

    • workspaceId: Your workspace ID. For more information, see Get an app ID and a workspace ID.

    • promptTemplateId: The ID of a built-in or custom prompt template. You can find the ID on the template card.

  3. Click Initiate Call to debug the API operation online.

    Example of a successful call:

    {   // Schema of Response
      "variables": [   // A list of template variables
        "platform",   // A template variable
        "topic",   // A template variable
        "num1",   // A template variable
        "num2"   // A template variable
      ],
      "promptTemplateId": "cfec40c311f14f3e976403059d8f0116",   // The template ID
      "requestId": "8C616xxx",   // The request ID
      "name": "Marketing Copy Generation",   // The template name
      "content": "You are a professional marketing copywriter with extensive experience on the ${platform} platform. Now, please write a highly engaging piece of ${platform} marketing content with \"${topic}\" as the core theme. The content must include a captivating and SEO-friendly title, and a detailed and emotionally compelling body. In the body, please insert at least ${num1} different emoji to increase interactivity and visual appeal. Additionally, based on this theme, design and provide up to ${num2} popular recommended tags that highly summarize the theme and attract the target audience.",   // The template content
    }

SDK

  1. Open the GetPromptTemplate API reference and click Debug.

  2. In the Configure Parameters panel, enter the workspaceId and promptTemplateId. After you enter the parameters, the workspaceId and promptTemplateId are automatically populated in the SDK example.

    • workspaceId: Your workspace ID. For more information, see Get an app ID and a workspace ID.

    • promptTemplateId: The ID of a built-in or custom prompt template. You can find the ID on the template card.

  3. On the debugging page, click SDK Example.

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

    For more information about how to obtain an AccessKey, see Obtain an AccessKey and AgentKey.

    On the right side of the OpenAPI Explorer page, click the SDK Example tab. Select the SDK version V2.0 (Recommended) and your target language, such as Java, to view the corresponding SDK example code.

Examples

Template

Description

Recommended scenarios

Template content

Generated output

Marketing Title Generation

Generates eye-catching titles for various channels.

Marketing and promotion

You are an expert at writing viral titles for [Xiaohongshu]. Generate [10] eye-catching titles on the theme of the [Hangzhou Asian Games], using the keywords [YYDS, bookmark, reveal]. Each title must be under [20] characters.

  1. [YYDS] Reveal the story behind the Hangzhou Asian Games!

  2. [Bookmark] Don't miss the highlights of the Asian Games!

  3. Hangzhou Asian Games [YYDS] interviews with gold medalists!

  4. [Reveal] A complete tour of the Asian Games venues!

  5. Asian Games [YYDS] Gold medal event highlights!

  6. [Bookmark] Heartwarming stories from Asian Games volunteers!

  7. Asian Games [YYDS] Exclusive tips from gold medal coaches!

  8. [Reveal] A food tour of the Hangzhou Asian Games!

  9. Hangzhou Asian Games [YYDS] Highlights from gold medal events!

More examples

Template

Description

Recommended scenarios

Template content

Generated output

Marketing Copy Generation

Generates high-quality promotional copy for various channels.

Marketing and promotion

You are an expert at creating viral marketing copy for [Xiaohongshu]. Create marketing content on the theme of [smart Bluetooth headphones]. Include a title, body text, and popular recommended tags.

Title: [Smart Bluetooth Headphones]: Your new music companion

Body: Are you tired of tangled wires and want to enjoy music anytime, anywhere? Then you cannot miss these smart Bluetooth headphones!

These headphones use the latest Bluetooth 5.0 technology for a stable connection and clear sound quality, delivering a high-quality audio experience whether you are listening to music, watching movies, or playing games.

They also support touch controls, allowing you to switch songs or answer calls with a simple tap, which makes them incredibly convenient.

Most importantly, they have a long battery life, providing up to 8 hours of use on a single charge to meet your needs for the entire day.

These smart Bluetooth headphones are also available in a variety of colors. Whether you prefer simple black and white or vibrant colors, you can find a style that suits you.

Purchase now and get a discount! Do not hesitate, act now!

Popular recommended tags: #SmartBluetoothHeadphones #WirelessMusic #TouchControl #LongBatteryLife #ColorfulOptions

Product Promotion Copy Generation

Quickly generate high-converting product endorsement copy.

Marketing and promotion, product promotion

You are an experienced product recommendation copywriter. Write a promotional endorsement in the style of [Xiaohongshu] for a [negative ion hair dryer]. Include the product's [appearance, performance, effects, and advantages] to attract potential consumers.

Title: [Negative Ion Hair Dryer]: Rejuvenate your hair

Body: Are you still troubled by dry, frizzy, and split-end hair? Then you cannot miss this negative ion hair dryer!

This hair dryer uses advanced negative ion technology to effectively reduce static, making your hair smoother and shinier.

Moreover, its heat is fully adjustable, meeting your needs whether you want to dry your hair quickly or give it gentle care.

Most importantly, its design is stylish and simple, adding a touch of beauty whether it is placed in the bathroom or bedroom.

Purchase now and get a discount! Do not hesitate, act now!

Popular recommended tags: #NegativeIonHairDryer #HairCare #AdjustableHeat #StylishDesign #DiscountOffer

Summary Extraction

An efficiency tool for extracting summaries and key points in office scenarios.

Office productivity tool, learning tool

You are a professional expert in summarizing article content. Please generate a summary of the provided article content. The word count should not exceed [200 words]. Article content: ["Green" is one of the core concepts for hosting the Hangzhou Asian Games, and "Zero-Waste Asian Games" is a crucial part of this "green" philosophy.

Cao Jiansong, a second-level inspector at the Hangzhou Municipal Bureau of Ecology and Environment, explained that "Zero-Waste Asian Games" is an initiative pioneered by Hangzhou. It refers to the comprehensive implementation of the "zero-waste" concept throughout the preparation process, strengthening the full lifecycle management of solid waste to minimize its generation.

According to reporters, Hangzhou has facilitated the construction of 33 "Zero-Waste Asian Games" venues, 81 "Zero-Waste Asian Games" hotels, and 4 "Zero-Waste Asian Games" factories. Additionally, a "Zero-Waste Asian Games" application scenario has been established to ensure platform-based management.

As a new concept, there was no mature experience to draw upon for the construction of a "Zero-Waste Asian Games." How did Hangzhou achieve this?

The principle of "renovate if possible, do not build" was adhered to for the Hangzhou Asian Games competition venues. Among the 56 competition venues, 44 were renovated or temporary, while the other 12 new venues were designed with full consideration for post-games use. The Hangzhou Olympic Sports Center Asian Games Squash Hall, for example, was temporarily converted from the original 4D exhibition hall of the Hangzhou International Expo Center, maximizing the use of existing facilities and equipment.

At the same time, Hangzhou introduced standards and specifications such as the "Design Guidelines for Green and Healthy Buildings for the Asian Games," actively promoting prefabricated buildings and renewable materials, which significantly reduced construction waste. Data shows that after design optimization, the total steel consumption for the Hangzhou Olympic Sports Center Stadium, the "Big Lotus," was 28,000 tons, about one-third less than that of similarly sized stadiums. The Hangzhou Olympic Sports Center Gymnasium, Swimming Pool, and Lin'an Culture and Sports Center use light-guiding tube powerless lighting systems for daily illumination, achieving up to 30% energy savings in lighting annually.

It is understood that in the Asian Village and reception hotels, the Hangzhou Asian Games promoted initiatives like pre-washed vegetables entering the village, centralized food preparation, and on-demand processing to eliminate food waste. Additionally, the Hangzhou Asian Games launched a "Cloud Asian Village" low-carbon account, encouraging "villagers" to earn points and redeem prizes through actions like the "Clean Plate Campaign," waste sorting, and plastic-free shopping.

]

The Hangzhou Asian Games has adopted "green" as its hosting philosophy, with the "Zero-Waste Asian Games" as a key component aimed at reducing solid waste generation. To this end, Hangzhou has promoted the development of multiple "zero-waste" venues and hotels and established a management platform. In the construction of competition venues, the principle of "renovate if possible, do not build" was followed, and the use of prefabricated buildings and renewable materials was actively promoted to reduce construction waste. Furthermore, Hangzhou has reduced food waste through measures such as pre-washed vegetables and centralized food preparation, and launched a "Cloud Asian Village" low-carbon account to encourage environmentally friendly actions among "villagers."

Copy Polishing

Polish and revise copy according to input requirements.

Office productivity tool, learning tool

You are a professional copy polishing expert. Please polish and rewrite the copy I provide. Use [modern language with rhetorical devices] to achieve a [more concise and engaging] effect. The copy is: [The weather today was really great. On my way to school, I saw a small cat playing in the flowers, and it looked very happy. After school, I shared this interesting experience with my mom.]

Original: The weather today was really great. On my way to school, I saw a small cat playing in the flowers, and it looked very happy. After school, I shared this interesting experience with my mom.

Polished: The weather today was absolutely wonderful! On my way to school, I came across a kitten frolicking among the flowers, looking utterly joyful. After getting home from school, I could not wait to share this delightful moment with my mom.

Copy Style Rewrite

Rewrite copy content in different styles according to input requirements.

Office productivity tool, learning tool

You are a professional copy style rewriting expert. Please rewrite the copy I provide in [3] different [Xiaohongshu] styles to be more [positive and uplifting]. My copy is: [An unchanging life, repeating the same routine day in and day out, can inevitably be a bit dull. However, this state of life is not uncommon in modern society. We often live the same life day in and day out for the sake of our livelihood or career.]

  1. Xiaohongshu style 1:

Although daily life may seem a bit dull, we can change our mindset to make every day more meaningful. We can try new things, challenge ourselves, and fill life with surprises. As long as we maintain a positive attitude, we can make a simple life more interesting.

  1. Xiaohongshu style 2:

Although we may be repeating the same life every day, we can change our habits to make life more beautiful. We can try waking up early to exercise, learning a new skill, or traveling to a new place. As long as we maintain a positive attitude, we can make life richer and more colorful.

  1. Xiaohongshu style 3:

Although we may be repeating the same life every day, we can change our attitude to make life more meaningful. We can try practicing gratitude, enjoying the present moment, or helping others. As long as we maintain a positive attitude, we can make a simple life more fulfilling.

Product Reviews

Generate e-commerce buyer-level product review copy according to input requirements.

Product promotion

You are an experienced e-commerce buyer. Please write [3] positive reviews for a [Bluetooth massage gun], highlighting its [lightweight and portable, high value for money] features. Each review should be at least [50 words] long.

  1. This Bluetooth massage gun is very lightweight and portable. I take it with me when I go to the gym or on business trips. It is also very convenient to use; just turn on my phone's Bluetooth, and I can control it directly, which is very hassle-free. And the price is very affordable, making it great value for money.

  2. This Bluetooth massage gun is the most lightweight and convenient massage tool I have ever used. It's so convenient to carry around, whether in my bag or in the car. The price is also very reasonable, offering excellent value. I am very satisfied with this product.

  3. This Bluetooth massage gun is the cheapest and most practical massage tool I have ever bought. I enjoy exercising and often feel muscle soreness. The massage effect of this gun is excellent, and it is very lightweight and portable, so I can use it anytime. I highly recommend this product.

Error codes

If a call fails and an error message is returned, see error codes to resolve the issue.

FAQ

Q: What is the difference between calling the GetPromptTemplate API and concatenating strings directly in your code?

A: Using the GetPromptTemplate API to manage prompts offers the following advantages:

  • Separate logic from content: You can update and optimize prompt content in the Model Studio console without modifying or redeploying your application code.

  • Centralized management and collaboration: Storing all prompts in a central location makes it easy for teams, such as prompt engineers and developers, to collaborate, manage versions, and reuse templates.

  • Consistency: Ensures the same prompt version and structure are used across different parts of your application or between different services, which avoids inconsistencies caused by manual maintenance.