This topic describes the multimodal interaction API based on the HTTP protocol.
Prerequisites
You must activate the service and obtain and configure an API key. To prevent security risks, configure the API key as an environment variable instead of hard coding it in your code.
Endpoint
Authentication
When you send an HTTP request, include the API key in the HTTP header. Replace your_api_key with your actual API key.
Message types
The HTTP protocol supports only text messages, which are JSON-formatted strings.
Send a request
Request - Input Message
You can send an HTTP request.
Top-level parameter | Second-level parameter | Type | Required | Description |
model | string | Yes | The name of the Alibaba Cloud Model Studio model. This is fixed to "multimodal-dialog". Copy and use this value directly. | |
input | directive | string | Yes | Instruction name: Request |
app_id | string | Yes | The ID of the application created by the customer (Get APP ID). You can view this ID on the "My Applications" page of the multimodal interaction development suite console. | |
dialog_id | string | No | The dialog ID. If you leave this empty, a new dialog is started. The server automatically generates a dialog ID and returns it in the response. Example format: "12345678-1234-1234-1234-1234567890ab" (36 characters). To continue a previous conversation, pass the dialog_id that the server returned. | |
text | string | Yes | The text to process.
| |
parameters | client_info | object | Yes | For parameter descriptions, see the parameters.client_info parameters table below. |
images | list[] | No | The image data to analyze. Only multimodal applications support image Q&A. For parameter descriptions, see the parameters.images parameters table below. | |
biz_params | object | No | Configure as needed. For parameter descriptions, see the parameters.biz_params parameters table below. |
Top-level parameter | Second-level parameter | Type | Required | Description |
|---|---|---|---|---|
user_id | string | Yes | The end user ID. Generate this ID based on your business rules to implement customized features for different end users. The maximum length is 36 characters. | |
device | uuid | string | No | A globally unique ID for the client. You must generate this ID and pass it to the software development kit (SDK). The maximum length is 40 characters. An end user can have multiple devices. Each device has a different UUID, but the user_id is the same. |
network | ip | string | No | The public IP address of the caller. |
location | latitude | string | No | The latitude of the caller. Submit this in scenarios that require the precise location of the client. |
longitude | string | No | The longitude of the caller. Submit this in scenarios that require the precise location of the client. | |
city_name | string | No | The city where the caller is located. This indicates the approximate location of the client. |
Top-level parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | The image type. Supported types are base64 and url. |
value | string | Yes | The image content.
|
Top-level parameter | Type | Required | Description |
|---|---|---|---|
user_defined_params | json object | No | Parameters to pass through to the agent. For information about the parameters passed by different agents, see Call official agents. |
user_prompt_params | json object | No | Used to set custom prompt variables. You can define the key and value in the JSON object. For information about how to configure custom prompt variables in the console, see Application configuration - Prompts. |
user_query_params | json object | No | Used to set custom dialog variables. You can define the key and value in the JSON object. For information about how to configure custom dialog variables in the console, see Application configuration - Dialog variables. |
Example
Text event
RespondingContent - Output Message
Top-level parameter | Second-level parameter | Type | Required | Description |
|---|---|---|---|---|
output | event | string | Yes | Event name: RespondingContent |
dialog_id | string | Yes | Dialog ID | |
round_id | string | Yes | The ID of the current interaction round. | |
llm_request_id | string | Yes | The request_id for the large language model (LLM) call. | |
text | string | Yes | The text output from the system. This is a streamed, incremental output. | |
spoken | string | Yes | The text used for speech synthesis. This is a streamed, incremental output. | |
finished | bool | Yes | Indicates whether the output is complete. | |
finish_reason | string | No | The reason the output finished. Currently, only one reason is available:
| |
extra_info | object | No | Other extension information. The following are supported:
|
Example
Error event
This event provides error information. For a description of error codes, see Multimodal interaction suite - Error codes.
Error - Output Message
Top-level parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Error code |
message | string | Yes | Error message |
request_id | string | Yes | Request ID |