GLiNER-2

Run Inference

Perform fast, schema-driven entity extraction, text classification, and structured data parsing through the hosted GLiNER 2 inference engine.

POST /gliner-2

Purpose

Use this endpoint to run Named Entity Recognition, Text Classification, or Structured Data Extraction without setting up local models.
GLiNER 2 unifies multiple information-extraction tasks in a single efficient forward pass optimized for CPU-based inference.

Typical use-cases include:

  • Extracting entities such as people, organizations, products, or places

  • Classifying text for sentiment, topic, or intent

  • Parsing structured fields from unstructured text such as invoices, contracts, or medical records

Endpoint

POST https://api.fastino.ai/gliner-2

Headers

x-api-key: pk_...
Content-Type: application/json

Request Body



Field

Type

Required

Description

text

string

Yes

The input text to analyze.

labels

object / list

Yes

Entity labels, class labels, or structured-field schema depending on task type.

threshold

float

Optional

Confidence threshold for predictions (default = 0.5).

task

string

Optional

Optional task specifier (e.g. "extract_json" for structured output).

schema

object

Optional

Schema definition for structured extraction (required if using "extract_json").

Example 1 – Entity Extraction

{
  "text": "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday.",
  "labels": ["company", "person", "product", "location"]
}

Example Response

{
  "entities": {
    "company": ["Apple"],
    "person": ["Tim Cook"],
    "product": ["iPhone 15"],
    "location": ["Cupertino"]
  }
}

Example 2 – Text Classification

{
  "text": "This laptop has great performance but poor battery life.",
  "labels": { "sentiment": ["positive", "neutral", "negative"] }
}

Example Response

{ "sentiment": "negative" }

Example 3 – Structured Extraction

{
  "task": "extract_json",
  "text": "iPhone 15 Pro Max with 256GB storage priced at $1199.",
  "schema": {
    "product": [
      "name::str::Product name",
      "storage::str::Storage capacity",
      "price::str::Price with currency"
    ]
  }
}

Example Response

{
  "product": [{
    "name": "iPhone 15 Pro Max",
    "storage": "256GB",
    "price": "$1199"
  }]
}

Example cURL

curl -X POST "https://api.fastino.ai/gliner-2" \
  -H "x-api-key: pk_test_123" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday.",
    "labels": ["company", "person", "product", "location"]
  }'

Response Fields



Field

Type

Description

entities

object

Map of detected entity labels to extracted text spans.

classification

object / string

For classification tasks, the predicted label(s).

structured_output

object

For structured extraction, key–value pairs following the provided schema.

Error Responses



HTTP Code

Error Code

Description

400

INVALID_REQUEST

Missing or malformed fields.

401

UNAUTHORIZED

Invalid or missing API key.

500

SERVER_ERROR

Internal inference error — retry with exponential backoff.

Example:

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Missing required field: text"
  }
}

Best Practices

  • Keep text under 8 KB per call for optimal latency.

  • Reuse the same model session for batch requests to leverage warm caching.

  • Use threshold ≥ 0.7 for precision-critical domains such as finance or healthcare.

  • Combine GLiNER 2 output with the Fastino Personalization API to enable user-specific extraction or context enrichment.

Summary

POST /gliner-2 provides unified, production-ready information extraction through Fastino’s hosted GLiNER 2 engine — efficient, accurate, and fully compatible with LLM pipelines.

On this page