Model inference


https://api.app.labelf.ai/v2/models/{model_id}/inference
This endpoint allows you to do inference on a single model that you have deployed
Response format
JSON
Authentication
Yes - Bearer token

Example cURL request


import requests

headers = {
    'Authorization': 'Bearer YOUR_BEARER_TOKEN',
}
json_data = {
    'texts': [
        'Breakfast was not tasty',
    ],
    'max_predictions': 2,
}

response = requests.post('https://api.app.labelf.ai/v2/models/YOUR_MODEL_ID/inference', headers=headers, json=json_data)

fetch('https://api.app.labelf.ai/v2/models/YOUR_MODEL_ID/inference', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer YOUR_BEARER_TOKEN',
        'Content-Type': 'application/json'
    },
    // body: '{ "texts": ["Breakfast was not tasty"], "max_predictions": 2 }',
    body: JSON.stringify({
        'texts': [
            'Breakfast was not tasty'
        ],
        'max_predictions': 2
    })
});

curl --location --request POST 'https://api.app.labelf.ai/v2/models/YOUR_MODEL_ID/inference' \
 --header 'Authorization: Bearer YOUR_BEARER_TOKEN' \ --header 'Content-Type: application/json' \
 --data-raw '{ "texts": ["Breakfast was not tasty"], "max_predictions": 2 }'

Example response


HTTP/1.1 200 OK 
Status: 200 OK 
Content-Type: application/json; 
charset=utf-8 
... 
[ 
	{ 
  	"text": "Breakfast was not tasty", 
    "predictions": [ 
    	{ 
      	"label": "positive", "score": 0.93 
      }, 
      {
      	"label": "neutral", "score": 0.03 
      } 
    ] 
	} 
]
Change Cookie Settings