Create an API from a model
Registering a large model as an API service on the Dataphin platform lets you manage it centrally. You can track API calls from different applications, apply traffic control, enable monitoring, and view call logs. This topic explains how to create an API from a model.
Step 1: Select the API creation method
In the top navigation bar of the Dataphin home page, choose Service > API development.
In the upper-left corner, select a service project and click API service in the left-side navigation pane. On the API page, click + Create API.
In the Create API dialog box, select Model API.
Step 2: Configure model API parameters
On the Create API page, configure the parameters.
Parameter
Description
Basic information
API name
The name of the API. It must meet the following requirements:
Can contain Chinese characters, letters, digits, and underscores (_).
Must be 4 to 100 characters in length.
Must start with a letter.
Must be globally unique.
Model
The name of the model. The name can be up to 256 characters long.
Protocol type
The API protocol. The supported protocols are OpenAI-compatible and DashScope.
Operation type
Defaults to GET and cannot be changed.
GET: Requests a specific resource from the server.
API group
Select an API group configured in the current project. To create an API group, see Create a service group.
Description
A brief description of the API. The description can be up to 128 characters long.
Protocol
The request protocol for the API. Supported protocols are HTTP and HTTPS.
HTTP: The HyperText Transfer Protocol (HTTP) is the most widely used network protocol.
HTTPS: If the gateway is configured as an Alibaba Cloud API Gateway (dedicated instance or shared instance), you can select HTTPS. Make sure the SSL certificate for your custom domain is valid. Otherwise, the API invocation may fail. To configure the SSL certificate, go to the Network Configuration page under Platform Management.
Invocation mode
The communication mode between the client and server for data retrieval or processing. You can select synchronous invocation or asynchronous invocation. The default is synchronous invocation.
Synchronous invocation: After sending a request, a client must wait for the server's response before sending another request. For complex queries, the response time can be long. Waiting also consumes server connections and increases the server load. This mode is suitable for scenarios that require high real-time performance and short processing time.
Asynchronous invocation: After sending a request, the client can continue with other operations without waiting for a response. The server notifies the client after the request is processed. When you retrieve data in batches, this mode can reduce the duplication of query results and allows you to use data service APIs to retrieve data. This mode is suitable for scenarios that have long processing time and low real-time requirements, such as batch processing.
Execution timeout
This parameter is configurable only when the invocation mode is asynchronous invocation. It is used to monitor the duration of SQL execution. The default value is 60 seconds, and the value must be a positive integer from 1 to 7,200 seconds (2 hours).
Timeout
The maximum duration for an API call. For synchronous invocation, the default value is 30 seconds, and you can set the value to a positive integer from 3 to 60. For asynchronous invocation, the default value is 600 seconds, and you can set the value to a positive integer from 3 to 7,200 (2 hours).
If an API call exceeds the specified timeout period, the system reports an error. This helps you promptly identify and resolve API call issues. For more information about how to view exceptions, see Manage monitoring APIs.
Version
The version number of the API. Each configuration has a version number to distinguish it from previous ones. The version number can be up to 64 characters long and must be unique within the API.
Response format
The default value is JSON.
Backend service configuration
Mode
Supported modes: Basic and Dev-Prod.
In Basic mode, the development, submission, and online environments read from the production database.
In Dev-Prod mode, the development and submission environments read from the development database, and the online environment reads from the production database.
Request method
The method for forwarding requests to the backend service. Only POST is supported.
POST: If you select POST, you can place request parameters in the request body.
API data source
Select an API data source to register the API. To create an API data source, see Create an API data source.
Service timeout
The timeout for a request forwarded to the backend service. If a backend service call exceeds the specified Service timeout period, the system reports an error. This helps you promptly identify and resolve API call issues. For more information about how to view exceptions, see Manage monitoring APIs.
Service path
The protocol and model types determine the service path. If the protocol type is OpenAI-compatible, the supported model types are chat and custom. If the protocol type is DashScope, the supported model types are chat, image generation, and custom. The system displays the corresponding service path for the selected model type.
For example, if the URL of the API data source is
http://dashscope.aliyuncs.com:*****/api/exampleand the service path is/compatible-mode/v1/chat/completions, the full URL of the backend service ishttp://dashscope.aliyuncs.com:*****/api/example/compatible-mode/v1/chat/completions.If you select a custom service path, the path must start with a forward slash (/) and cannot exceed 128 characters in length.
Request parameters
Parameter name
The name of a public parameter that users provide in API calls. The name can be up to 128 characters long.
Parameter position
Supported positions: Headers, Parameters, and Body.
Headers: The parameter is added to the request header.
Parameters: The parameter is appended to the data source URL.
Body: If multiple parameters exist, the system encapsulates them into a single request body.
Parameter type
When the parameter location is Headers or Parameters, the supported parameter types are DOUBLE, FLOAT, STRING, DATE(yyyy-MM-dd HH:mm:ss), BOOLEAN, INT, LONG, SHORT, and BIGDECIMAL. You must select the parameter type for the field that is bound to the parameter name.
When the parameter location is Body, in addition to the preceding parameter types, you can also use Array(int), Array(string), Object, Array(double), Array(float), Array(Date(yyyy-MM-dd HH:mm:ss)), Array(boolean), Array(long), Array(short), Array(BigDecimal), and Array(Object).
Default value
If a value is not provided in the API call, the system uses this default value. The value can be up to 1,000 characters long. There is no character limit for the STRING type.
Example
An example value for the parameter to help developers. The value can be up to 1,000 characters long.
Description
A brief description of the request parameter. The description can be up to 1,000 characters long.
Required
If a parameter is required, an API call will fail if the parameter is omitted.
Test
You can test the API to verify that the response from the large model meets your expectations.
After you configure the request parameters, click Test. In the Test Request Sending dialog box, enter test values for the parameters and click Start Test. The system packages the request parameters, sends the request body to the large model, and then returns the response content.
Intelligent generation
If the operation type is GET and you have tested the request parameters, click the Smart Add button. The system will automatically extract the first-level parameters from the response and populate the response parameter list with the parameter name, response parameter value path, and parameter type.
Response parameters
Parameter name
Required. The name of the public parameter displayed to the user in the API response. The name can be up to 128 characters long.
Response parameter value path
Only the JSON format is supported. If the response data is nested within multiple layers, you must configure the corresponding path for the response parameter. You can click View Configuration Instructions to view examples for configuring the value path of the response parameter, or enter a keyword to search for a matching path.

Parameter type
After you test the response parameter value path, the system automatically detects the data type based on the test result. You can select the data type that corresponds to the bound field of the parameter. Supported types include DOUBLE, FLOAT, STRING, DATE(yyyy-MM-dd HH:mm:ss), BOOLEAN, INT, LONG, SHORT, BIGDECIMAL, Array(int), Array(string), Object, Array(double), Array(float), Array(Date(yyyy-MM-dd HH:mm:ss)), Array(boolean), Array(long), Array(short), Array(BigDecimal), and Array(Object).
Example
An example value for the parameter to help developers. The value can be up to 1,000 characters long.
Description
A brief description of the response parameter. The description can be up to 1,000 characters long.
Click Submit to create the API.
Next steps
After you create an API, you must test and publish it to the Data Service Market so that applications can call it. For more information, see Test and publish an API.
To delete an API, manage its versions, or transfer its ownership, see Manage APIs.