Notebook
启动Notebook实例自定义服务
1.接口说明
接口路径:/ai/openapi/v2/notebook/customize-service/actions/start
请求方式:POST
请求数据类型:
接口描述:启动Notebook实例自定义服务
2.请求消息
请求参数:
Headers:
| 名称 | 类型 | 必填 | 描述 | 示例 |
|---|---|---|---|---|
| token | string | 是 | 接口凭证 | eyJhbGciOiJIUzI1N... |
参数:
| 名称 | 类型 | 必填 | 描述 | 示例 |
|---|---|---|---|---|
| id | string | 是 | notebookId | 1896050410550136833 |
| customizePort | string | 是 | 自定义服务端口 | 1223 |
| command | string | 否 | 自定义服务启动命令 | python /root/SimpleSDXL/entry_with_update.py --listen 0.0.0.0 --port 1223 > /root/sd.log 2>&1 |
3.请求示例
cURL请求示例
shell
curl --location --request POST 'https://scnet-demo.accloud.cn/ai/openapi/v2/notebook/customize-service/actions/start' \
--header 'token: <Token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"id":"1896050410550136833",
"command":"python /root/SimpleSDXL/entry_with_update.py --listen 0.0.0.0 --port 1223 > /root/sd.log 2>&1",
"customsizePort":"1223"
}'Java请求示例
java
import okhttp3.*;
public class StartCustomizeServiceDemo {
public static final String TOKEN = "<Token>";
public static final String URL = "https://scnet-demo.accloud.cn/ai/openapi/v2/notebook/customize-service/actions/start";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
String jsonBody = "{\n" +
" \"id\": \"1896050410550136833\",\n" +
" \"command\": \"python /root/SimpleSDXL/entry_with_update.py --listen 0.0.0.0 --port 1223 > /root/sd.log 2>&1\",\n" +
" \"customizePort\": \"1223\"\n" +
"}";
RequestBody body = RequestBody.create(mediaType, jsonBody);
Request request = new Request.Builder()
.url(URL)
.method("POST", body)
.addHeader("token", TOKEN)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}Python请求示例
python
import requests
import json
url = "https://scnet-demo.accloud.cn/ai/openapi/v2/notebook/customize-service/actions/start"
payload = json.dumps({
"id": "1896050410550136833",
"command": "python /root/SimpleSDXL/entry_with_update.py --listen 0.0.0.0 --port 1223 > /root/sd.log 2>&1",
"customizePort": "1223"
})
headers = {
"token": "<Token>",
"Content-Type": "application/json"
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)4.响应消息
返回参数:
| 名称 | 类型 | 描述 | 示例 |
|---|---|---|---|
| msg | string | 信息 | success |
| code | string | 状态码 | 0 |
| data | object | ||
| execSuccess | boolean | 启动结果 | false |
| errorMsg | string | 错误信息 | |
| output | string | 执行命令输出 |
返回示例:
json
{
"code": "0",
"msg": "success",
"data": {
"execSuccess": false,
"errorMsg": "根据您提供的端口,未检测到可用的服务。若您的服务为特定的API接口,系统将自动建立通路,对应的外部地址为:https://c-1896476639463936002.ksai.scnet.cn:58043",
"output": null
}5.错误码
| 错误码 | 说明 |
|---|---|
| 0 | 成功 |
| 10001 | 内部错误 |
| 10003 | 参数不全 |
| 10004 | 参数无效 |
| 10007 | 用户已被冻结 |
| 10008 | 权限不足 |
| 10009 | 没有权限访问接口 |
| 10010 | 文件校验失败 |
| 10011 | 文件过大 |
| 10012 | 连接中断 |
| 716865 | 创建任务错误 |