原生 GLiNER
原生 GLiNER-2 推理
使用统一的 GLiNER schema 运行同步的原生 GLiNER-2 提取和分类,并附有实体提取和分类示例。
POST
https://api.fastino.ai
/
v1
/
gliner-2
原生 GLiNER-2 推理
curl --request POST \
--url https://api.fastino.ai/v1/gliner-2 \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fastino.ai/v1/gliner-2"
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', 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",
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"
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")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/gliner-2")
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
运行同步的原生 GLiNER-2 提取和分类。此页面上的 OpenAPI 面板是所有请求字段和响应字段的
事实来源。
当你需要指定托管模型、微调模型、推理持久化或与 OpenAI 兼容的信封时,请使用
POST /v1/chat/completions。此原生端点会为你选择
Fastino GLiNER-2 基础模型。
请求 schema
请求必须包含:text:一个字符串或字符串数组。schema:统一的 GLiNER schema 字典。旧版扁平标签数组已弃用。
threshold、include_confidence、include_spans 和 format_results。
请省略 task;它是已弃用的旧版提示,操作类型由 schema 确定。
实体提取示例
curl -X POST "https://api.fastino.ai/v1/gliner-2" \
-H "X-API-Key: $FASTINO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Apple CEO Tim Cook introduced the iPhone in Cupertino.",
"schema": {
"entities": [
{"name": "person", "description": "named individual"},
{"name": "organization", "description": "business or institution"},
{"name": "product", "description": "named commercial product"},
{"name": "location", "description": "city, region, or place"}
]
},
"threshold": 0.5,
"include_confidence": true,
"include_spans": true
}'
分类示例
curl -X POST "https://api.fastino.ai/v1/gliner-2" \
-H "X-API-Key: $FASTINO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "The replacement arrived quickly and works perfectly.",
"schema": {
"classifications": [
{
"task": "sentiment",
"labels": ["positive", "negative", "neutral"],
"multi_label": false,
"top_k": 1
}
]
}
}'
POST /v1/chat/completions GLiNER schema 参考。
响应 schema
成功的响应包含:result:按 schema 结构返回的提取或分类结果。token_usage:已处理的输入 token 数量。
{
"result": {
"entities": [
{
"text": "Apple",
"label": "organization",
"score": 0.99,
"start": 0,
"end": 5
}
]
},
"token_usage": 10
}
text 为数组时,result 也是一个数组,顺序与输入一致。请勿通过
POST /v1/chat/completions 发送这种批量结构;请分别提交这些对话。此页面对您有帮助吗?
⌘I
原生 GLiNER-2 推理
curl --request POST \
--url https://api.fastino.ai/v1/gliner-2 \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.fastino.ai/v1/gliner-2"
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', 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",
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"
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")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fastino.ai/v1/gliner-2")
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
