The Lindorm AI engine provides a set of RESTful APIs. You can use curl commands to perform operations such as model management and inference. This topic shows how to use curl to call these APIs.
Prerequisites
You have enabled the AI engine. For more information, see Enable the AI engine.
You have added the IP address of your client to the allowlist of your Lindorm instance. For more information, see Configure an allowlist.
Parameters
The following parameters apply to all examples in this topic.
Parameter | Description | How to obtain |
url | The endpoint for connecting to the AI engine. | On the Database Connection page, click the AI Engine tab to obtain the endpoint, username, and password. |
username | The username and password to access the AI engine. | |
password |
Connection example
curl -X GET "http://ld-bp1hq5192030n****-proxy-ai-vpc.lindorm.aliyuncs.com:9002/v1/ai/models/list" \
-H "x-ld-ak: test" \
-H "x-ld-sk: test" 9002 is the port number and is required.
Model management
Create a model
Create a model named bge_m3_model in the AI engine.
curl -X POST "http://<url>/v1/ai/models/create" \
-H "x-ld-ak: <username>" \
-H "x-ld-sk: <password>" \
-H "Content-Type: application/json" \
-d '{
"model_name": "bge_m3_model",
"model_path": "huggingface://BAAI/bge-m3",
"task": "FEATURE_EXTRACTION",
"algorithm": "BGE_M3"
}' Response:
{"code": 0,"msg": "SUCCESS","data": null,"success": true}List all models
curl -X GET "http://<url>/v1/ai/models/list" \
-H "x-ld-ak: <username>" \
-H "x-ld-sk: <password>" Response:
{
"code": 0,
"msg": "SUCCESS",
"data": {
"models": [{
"name": "bge_m3_model",
"status": "READY",
"created_time": "...",
"updated_time": "...",
...
}, {
"name": "bge_model",
"status": "READY",
...
}]
},
"success": true
"request_id":"..."
}Get model details
curl -X GET "http://<url>/v1/ai/models/bge_m3_model/status" \
-H "x-ld-ak: <username>" \
-H "x-ld-sk: <password>" Response:
{
"code": 0,
"msg": "SUCCESS",
"data": {
"name": "bge_m3_model",
"status": "READY",
"task_type":"FEATURE_EXTRACTION",
"algorithm":"BGE_M3",
"settings": "...",
"error":"...",
"progress": "...",
...
},
"success": true
}Delete a model
Delete the bge_m3_model model.
curl -X POST "http://<url>/v1/ai/models/bge_m3_model/drop" \
-H "x-ld-ak: <username>" \
-H "x-ld-sk: <password>"Response:
{"code": 0,"msg": "SUCCESS","data": null,"success": true}Model inference
Run inference with an existing model
curl -X POST "http://<url>/v1/ai/models/bge_m3_model/infer" \
-H "x-ld-ak: <username>" \
-H "x-ld-sk: <password>" \
-H "Content-Type: application/json" \
-d '{"input":["你好","我们"]}' \This returns the following inference result:
{
"code": 0,
"msg": "SUCCESS",
"data": [[0.027204733341932297,0.004229982383549213, ...],
[-0.05367295444011688,0.022600287571549416, ...]],
"success": true
}Parameter adjustment
Adjust the parameters for a deployed model.
curl -X POST "http://<url>/v1/ai/models/bge_m3_model/update_config" \
-H "x-ld-ak: <username>" \
-H "x-ld-sk: <password>" \
-H "Content-Type: application/json" \
-d '{"instance_count": "2"}' \A successful adjustment returns the following response:
{"code": 0,"msg": "SUCCESS","data": null,"success": true}