Application gateway API reference
Request parameters
Parameter | Type | Description | Example value | ||
input | Object | Contains the input data. | - | ||
messages | Array[Object] | An array of message objects representing the conversation history. | - | ||
role | String | The role of the message author. Valid values are:
| assistant | ||
content | String | The content of the message. If the role is | Hello, valued Alibaba Cloud user. This is a test of the opening message. We apologize for any inconvenience this may cause. | ||
biz_params | Object | Custom business parameters. | {"city": "China (Hangzhou)"} | ||
parameters | Object | Model-specific parameters, such as | 1 | ||
incremental_output | Boolean | Specifies whether to enable incremental output in streaming output mode. | true | ||
flow_stream_mode | String | The streaming output mode for a workflow application. Must be set to | agent_format | ||
call_id | String | The unique identifier for the call. This must be the same ID that was returned when the call was initiated. | 147417592084^1341******** | ||
session_id | String | A unique identifier for the conversation session. Note This field is optional and not sent by default. | 147417592084^1341******** | ||
Example request
{
"input": {
"messages": [
{
"role": "system",
"content": "You are an Alibaba Cloud customer service assistant. Your task is to play a standard welcome message."
},
{
"role": "assistant",
"content": "Hello, valued Alibaba Cloud user. This is a test of the opening message. We apologize for any inconvenience."
},
{
"role": "user",
"content": "What is this about?"
}
],
"biz_params": {
"city": "China (Hangzhou)"
}
},
"debug": {},
"parameters": {
"incremental_output": true,
"flow_stream_mode": "agent_format"
},
"call_id": "147417592084^1341********"
}Response fields
Parameter | Type | Description | Example value | ||
output | Object | Contains the results of the API call. | - | ||
text | String | The model-generated response. | I am an Alibaba Cloud customer service assistant | ||
finish_reason | String | The reason the model stopped generating content. A
| null | ||
session_id | String | The unique identifier for the current conversation session. | 147417592084^1341******** | ||
request_id | String | The unique identifier for the Model Studio API call. Note This field is optional and may not be included in every response. | 1111111-2222-3333-4444-********** | ||
Example response
{
"output": {
"session_id": "c57cb4cb62a8************",
"finish_reason": "null",
"text": "I am an Alibaba Cloud customer service assistant"
},
"usage": {
"models": [
{
"input_tokens": 158,
"output_tokens": 7,
"model_id": "qwen-plus"
}
]
},
"request_id": "1111111-2222-3333-4444-555555555555"
}Verify gateway integration with SSE
Before integrating your large model, you can use SSE streaming to validate its compatibility with the communication engine gateway.
The integration uses HTTP, and the connection must support SSE streaming output.
Run the following cURL command to test the integration.
Before running the command, replace the following placeholders: https://********** with your URL (the Model Address on the configuration page), $AUTH with your authorization code (the Authorization Code on the configuration page), and the model value with your model (the Base Model in Model Configuration settings).
Request:
curl -X POST \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "x-dashscope-sse: enable" \
-d '{
"input": {
"messages": [
{
"role": "assistant",
"content": "This is a test opening message."
},
{
"role": "user",
"content": "What is this about?"
}
]
},
"debug": {},
"parameters": {
"incremental_output": true,
"flow_stream_mode": "agent_format"
},
"call_id": "147417592084^1341********"
}' \
"https://**********"
Output:
data:{"output":{"session_id":"c57cb4cb62a8************","finish_reason":"null","text":"I am an Alibaba Cloud customer service assistant"},"usage":{"models":[{"input_tokens":158,"output_tokens":7,"model_id":"qwen-plus"}]},"request_id":"1111111-2222-3333-4444-555555555555"}