Skip to main content
Invocation

Passing Custom Parameters via API

This guide explains how to invoke Alibaba Cloud Bailian workflow applications using either the DashScope API or the OpenAI Responses API-compatible interface to pass custom parameters.

How It Works

When invoking a workflow application, dynamic parameters are uniformly encapsulated within the input object, which contains two key fields:
  • prompt: Contains the user's primary input. This content is automatically mapped to the built-in variable {{query}} in the workflow—no manual definition required.
  • biz_params: A key-value dictionary for passing custom business parameters (e.g., {"city": "Hangzhou"}). These parameters must be pre-defined in the workflow’s Start Node, after which they become globally available and can be referenced anywhere in the workflow—including in LLM node prompts—using the syntax {{parameter_name}}.

How to Use

Prerequisites

  • You must have configured your API Key and set it as an environment variable. If using the DashScope SDK, ensure it is installed.
  • Application ID (YOUR_APP_ID): Navigate to the Application Management page in the Bailian console to view your application list and retrieve the ID from the target application card.

Getting Started

This guide uses “querying administrative divisions by city name” as an example to demonstrate how to invoke a workflow application and pass custom parameters.

Step 1: Configure the Workflow

  1. Go to the Application Management page in the Bailian console and create or edit a Workflow Application.
  2. In the Variables configuration panel of the Start Node, add a custom parameter—for example, a String-type variable named city.
  3. Reference the custom variable in prompts of downstream nodes (e.g., LLM nodes). Example prompt: Query the administrative divisions of {{city}}. The user's question is: {{query}}.
  4. Publish the application.

Step 2: Make the API Call

Pass the city parameter via the biz_params field and the query via the prompt field. When using the OpenAI Responses API-compatible interface, extend biz_params using the extra_body field.
import os
from http import HTTPStatus
from dashscope import Application

# Passing custom parameters to a workflow application
biz_params = {"city": "Hangzhou"}
response = Application.call(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    app_id='YOUR_APP_ID',  # Replace with your actual app ID
    prompt='Query the administrative divisions of this city',
    biz_params=biz_params  # Pass business parameters
)

if response.status_code != HTTPStatus.OK:
    print(f'request_id={response.request_id}')
    print(f'code={response.status_code}')
    print(f'message={response.message}')
    print(f'See documentation: https://help.aliyun.com/zh/model-studio/developer-reference/error-code')
else:
    print(f'{response.output.text}')
Sample Response
Hangzhou, the capital city of Zhejiang Province, comprises 10 municipal districts: Shangcheng District, Gongshu District, Xihu District, Binjiang District, Xiaoshan District, Yuhang District, Linping District, Qiantang District, Fuyang District, and Lin'an District.
Passing Custom Parameters via API - 阿里云百炼 Agent Studio