This operation generates SQL statements based on the current query information and associated data tables. This API is suitable for scenarios where your database is stored locally and cannot be accessed by Xiyan. You can associate a virtual data source with Xiyan, call this API to generate the SQL statements, and then parse and execute them locally. For more information, see the best practices document.
Try it now
Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.
RAM authorization
The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:
-
Action: The actions can be used in the
Actionelement of RAM permission policy statements to grant permissions to perform the operation. - API: The API that you can call to perform the action.
- Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.
-
Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.
- For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the
Resourceelement of the policy. - For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the
Resourceelement of the policy.
- For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the
- Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.
- Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.
Action | Access level | Resource type | Condition key | Dependent action |
|---|---|---|---|---|
dataanalysisgbi:RunSqlGeneration | none | *All Resource
| None | None |
Request syntax
Request parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| workspaceId | string | Yes | The ID of the Alibaba Cloud Model Studio workspace used for the current request. | llm-2v3934xtp49esw64 |
| body | object | No | Request body parameters. | |
| specificationType | string | No | The version information specified for the current request. If empty, the default workspace version is used. Valid values:
| STANDARD_MIX |
| query | string | Yes | The query entered by the user. | What are the top ten products by sales? |
| sessionId | string | No | The message session ID. Multiple request IDs can belong to the same session ID. | d5eced84-fd25-43ee-a245-adb4e4a8c3be |
Response elements
Element | Type | Description | Example |
|---|---|---|---|
object | SseEmitter | ||
| data | object | Return information. | |
| errorMessage | string | Error message. | Access was denied, message: No such namespace namespaces/tech-scp-chain7. |
| event | string | Event type. Valid values:
| sql |
| evidence | string | Information used for auxiliary model inference. | This year is 2024 |
| requestId | string | The ID of the current request. | DA2578F7-88A5-5D6E-9305-33E724E97D60 |
| rewrite | string | The rewritten user input. | Query all keyword data and display it as a pie chart |
| selector | array | List of specific table names retrieved. | |
string | The name of the specific table retrieved. | table_name1 | |
| sessionId | string | Conversation ID. | f64c38dd-a235-4bb4-ae6c-79eaedcba699 |
| sql | string | The SQL statement generated for the current conversation. | select p.product_id, p.product_name, sum(o.quantity) as total_sales from products p join orders o on p.product_id = o.product_id where o.order_date between '2022-10-22' and '2024-10-22' group by p.product_id, p.product_name having total_sales > 5 |
| sqlError | string | If the task execution fails, this field reports the reason for the failure. | Can not issue data manipulation statements with executeQuery() |
| chat | object | ||
| text | string |
Examples
Success response
JSON format
Error codes
HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 401 | Internal.Error | Bad Request: Internal Error. | Internal error, please contact customer service personnel to troubleshoot |
| 401 | NoAuth | Bad Request: Workspace.Illegal.Auth. | The current account does not have the permission to the specified business space. |
| 401 | NoResourceAuth | Bad Request: Resource Auth Error. | If you do not have permission for the requested resource, make sure that the requested resource belongs to the business space in the current parameter. |
| 401 | SystemOperationInProgress | Xiyan GBI is learning your previous modifications. Please try again later. |