推理
获取模型状态
在发送推理流量之前,检查模型是就绪、启动中还是冷状态。
GET
https://api.fastino.ai
/
v1
/
model-status
/
{model_id}
获取模型状态
curl --request GET \
--url https://api.fastino.ai/v1/model-status/{model_id} \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fastino.ai/v1/model-status/{model_id}"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.fastino.ai/v1/model-status/{model_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fastino.ai/v1/model-status/{model_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.fastino.ai/v1/model-status/{model_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.fastino.ai/v1/model-status/{model_id}")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/model-status/{model_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyGET /v1/model-status/{model_id}
报告模型现在是否可以提供推理服务。state 为 ready、starting 或 cold;在 retry_after_seconds 之后再次轮询,直到其为 ready。模型 ID 可能包含 /;请在路径中直接发送,无需编码。
每个 API 服务器只报告其自身观察到的状态,因此在预热调用之后,状态可能会短暂地仍显示为 cold;请继续轮询。
相关指南: 重试与模型预热
请求示例
MODEL_ID=fastino/gliner2.5-multi-v1
curl "https://api.fastino.ai/v1/model-status/$MODEL_ID" \
-H "X-API-Key: $FASTINO_API_KEY"
响应示例
{
"model": "fastino/gliner2.5-multi-v1",
"state": "starting",
"warming_for_seconds": 42,
"retry_after_seconds": 15
}
此页面对您有帮助吗?
⌘I
获取模型状态
curl --request GET \
--url https://api.fastino.ai/v1/model-status/{model_id} \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fastino.ai/v1/model-status/{model_id}"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.fastino.ai/v1/model-status/{model_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fastino.ai/v1/model-status/{model_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.fastino.ai/v1/model-status/{model_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.fastino.ai/v1/model-status/{model_id}")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/model-status/{model_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body
