Inference API

Complete guide to making API requests and understanding responses from the Onairos Inference API.

Updated 24 January 2026
apiinferenceresponsemanual

Inference API

This guide covers how to make requests to the Onairos Inference API and understand the responses.

Making API Requests

When autoFetch is Disabled

If you set autoFetch = false, you'll receive the API URL and token via window.postMessage:

useEffect(() => {
  const handleMessage = (event) => {
    if (event.data?.source === 'content-script' && 
        event.data?.type === 'API_URL_RESPONSE') {
      const { apiUrl, accessToken } = event.data;
      fetchOnairosData(apiUrl, accessToken);
    }
  };
  
  window.addEventListener('message', handleMessage);
  return () => window.removeEventListener('message', handleMessage);
}, []);
Token Expiration

Access tokens are short-lived (1 hour) and only work on your registered domain.

Request Format

FieldTypeRequiredDescription
textStringYesText input for inference
categoryStringYesCategory of the content
img_urlStringNoURL of associated image
const response = await fetch(apiUrl, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`
  },
  body: JSON.stringify({
    Input: {
      item1: { text: "Product description", category: "fashion" },
      item2: { text: "Another item", category: "lifestyle", img_url: "https://..." }
    }
  })
});

const data = await response.json();

Response Format

Sentiment Scores

Sentiment predictions return scores between 0-1 indicating how much the user would like each input item:

{
  "output": [
    [[0.9998]],
    [[0.0013]]
  ]
}
ScoreMeaning
0.9+User will highly engage/like this content
0.5-0.9Moderate positive response
<0.5User likely won't engage

Personality Traits

If the user authorized trait sharing:

{
  "Traits": {
    "positive_traits": {
      "creativity": 9.7,
      "empathy": 9.6,
      "curiosity": 9.1
    },
    "traits_to_improve": {
      "patience": 1.7,
      "organization": 3.6
    }
  }
}

Traits are scored 0-10. Use these to personalize experiences, recommendations, and interactions.

Next Step

See Example Usage for practical code showing how to use this data.