原生 GLiNER
提交异步 GLiNER-2 作业
当输入超过一百万 token 或可能超过同步请求超时时间时,提交超大型 GLiNER-2 输入以进行异步处理。
POST
https://api.fastino.ai
/
v1
/
gliner-2
/
async
提交异步 GLiNER-2 作业
curl --request POST \
--url https://api.fastino.ai/v1/gliner-2/async \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fastino.ai/v1/gliner-2/async"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.fastino.ai/v1/gliner-2/async', 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/gliner-2/async",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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/gliner-2/async"
req, _ := http.NewRequest("POST", 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.post("https://api.fastino.ai/v1/gliner-2/async")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/gliner-2/async")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyPOST /v1/gliner-2/async
提交超大型 GLiNER-2 输入以进行异步处理。当输入超过一百万 token,或处理时间可能超过同步
请求超时时间时,请使用此端点。
此页面上的 OpenAPI 面板是所有请求字段和 202 响应字段的事实来源。请求使用与
POST /v1/gliner-2 相同的原生 GLiNER schema。
请求示例
curl -X POST "https://api.fastino.ai/v1/gliner-2/async" \
-H "X-API-Key: $FASTINO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "A very large document to process asynchronously...",
"schema": {
"entities": [
{"name": "person", "description": "named individual"},
{"name": "organization", "description": "business or institution"}
]
},
"threshold": 0.5,
"include_confidence": true,
"include_spans": true
}'
text 也可以是字符串数组。请省略已弃用的 task 字段;统一 schema 会确定提取、分类、
结构或关系操作。
已接受响应
该端点会立即返回 HTTP202。以下示例负载缩短了 message;服务会返回包含所返回作业 ID
的具体轮询路径。
{
"job_id": "3f08a17f-777a-4aa6-8ec5-879df37775a8",
"status": "accepted",
"estimated_tokens": 1284307,
"message": "Job queued. ..."
}
job_id,然后使用同一 API 密钥轮询
GET /v1/gliner-2/jobs/{job_id}。
作业的作用范围限定于已认证的用户。此页面对您有帮助吗?
⌘I
提交异步 GLiNER-2 作业
curl --request POST \
--url https://api.fastino.ai/v1/gliner-2/async \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fastino.ai/v1/gliner-2/async"
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.fastino.ai/v1/gliner-2/async', 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/gliner-2/async",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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/gliner-2/async"
req, _ := http.NewRequest("POST", 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.post("https://api.fastino.ai/v1/gliner-2/async")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/gliner-2/async")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body
