部署详情(LoRA)
LoRA模型服务详情。
GET
https://api.alayanew.com/api/serverless-infer/v1/deployment/{serviceId}
Authorizations
Authorizations:StringHeaderRequired
用户可通过已获取Open API Key做验证,例如:plain Credential=[YOUR_AK],Signature=[YOUR_SK]。
Path Parameters
serviceId:StringRequired
服务ID。
Response
状态码:application/json
200
serviceId:String
服务ID。
status:String
状态。
serviceUrl:String
服务URL。
apiKey:String
API Key。
baseServiceId:String
基模型服务ID。
namespace:String
弹性容器集群(VKS)NameSpace。
modelId:String
模型ID。
name:String
服务名称。
servedName:List<String>
模型标识。
cURL
Python
JavaScript
Go
Java
curl --location --request GET 'https://api.alayanew.com/api/serverless-infer/v1/deployment/38fbfc3d-6a88-4c35-b8b6-9efc83949d47'
--header 'Authorization:Authorization:plain Credential=YOUR_AK,Signature=YOUR_SK'
--header 'Content-Type: application/json'
200
400
401
403
404
500
{
"serviceId":" service ID",
"status":"string 服务状态",
"serviceUrl":"",
"apiKey":"",
"baseServiceId":"requeired, 基模型服务id",
"modelId": "String, 模型ID",
"name":"string , 服务展示名称由用户自定义",
"servedName": "string, "
}
服务状态
服务状态(status)流转详情如下图所示。
服务状态
服务状态(status)流转详情如下图所示。
服务调用
用户在部署模型服务后,可通过指定模型的参数来调用该服务。调用服务的代码示例如下所示。
- cURL
- Python
- JavaScript
- Go
- Java
curl --location --request POST '[serviceUrl]/v1/chat/completions' \
--header 'apiKey: [apiKey]' \
--data-raw `{ "stream":false,
"messages": [{"role":"user", "content":"你是谁,能干嘛"}],
"model":"[servedName]"}`
import requests
url = "[serviceUrl]/v1/chat/completions"
headers = {
"apiKey": "[apiKey]"
}
data = {
"stream": False,
"messages": [
{
"role": "user",
"content": "你是谁,能干嘛"
}
],
"model": "[servedName]"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const axios = require('axios');
const url = '[serviceUrl]/v1/chat/completions';
const headers = {
'apiKey': '[apiKey]'
};
const data = {
stream: false,
messages: [
{
role: 'user',
content: '你是谁,能干嘛'
}
],
model: '[servedName]'
};
axios.post(url, data, { headers })
.then(response => {
console.log(response);
})
.catch(error => {
console.error('请求失败:', error);
});
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "[serviceUrl]/v1/chat/completions"
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
}
type RequestBody struct {
Stream bool `json:"stream"`
Messages []Message `json:"messages"`
Model string `json:"model"`
}
body := RequestBody{
Stream: false,
Messages: []Message{
{Role: "user", Content: "你是谁,能干嘛"},
},
Model: "[servedName]",
}
jsonData, _ := json.Marshal(body)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("apiKey", "[apiKey]")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
import okhttp3.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class Test {
public static void main(String[] args) {
String OPENAI_API_KEY = "[apiKey]";
String OPENAI_API_BASE = "[serviceUrl]/v1/chat/completions";
String model = "[servedName]";
OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.MINUTES)
.writeTimeout(10, TimeUnit.MINUTES)
.build();
String jsonInputString = "{"
+ "\"stream\":false,"
+ "\"messages\":[{\"role\":\"user\",\"content\":\"你是谁,能干嘛\"}],"
+ "\"model\":\"" + model + "\""
+ "}";
System.out.println(jsonInputString);
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, jsonInputString);
Request request = new Request.Builder()
.url(OPENAI_API_BASE)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("apiKey", OPENAI_API_KEY)
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
} catch (IOException e) {
e.printStackTrace();
}
}
}