Returns JSON with the sentiment of English text (positive or negative with a confidence score) from DistilBERT SST-2 on Workers AI, for one text or a batch of up to 20.
Use this when you need sentiment analysis of text such as reviews, comments or headlines in English.
Do not use for neutral or emotion labels, non-English text or aspect-level sentiment.
Price: 0.004 USDC per call (x402, eip155:8453). Typical response time: 1500 ms (p95).
POST https://x402-gateway.blackwoodstate8.workers.dev/v1/sentiment. A request without payment gets 402 Payment Required with the
PAYMENT-REQUIRED header; any x402 client signs an EIP-3009 authorization and retries with
PAYMENT-SIGNATURE (or X-PAYMENT). Invalid input is answered with 400 and not charged.
curl -i -X POST https://x402-gateway.blackwoodstate8.workers.dev/v1/sentiment -H 'content-type: application/json' -d '{"texts":["The checkout was fast and the support team was great.","The package arrived broken and nobody answered my emails."]}'
| Pay to | 0xd25cA2Ea2a5017b4297157b0635E3FDBB26A326A |
|---|---|
| Asset | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (USDC) |
| Amount | 4000 atomic units (0.004 USDC) |
| Authorization window | 60 s |
Streamable HTTP at https://x402-gateway.blackwoodstate8.workers.dev/mcp, tool blackwood_text_sentiment. Payment goes in
_meta["x402/payment"]; without it the tool returns the payment requirements.
| Field | Type | Meaning |
|---|---|---|
text (optional) | string | One English text to classify, e.g. The checkout was fast (up to 2000 characters) |
texts (optional) | array | Or a batch of up to 20 English texts, e.g. ["Great support", "Broken on arrival"] |
Example:
{
"texts": [
"The checkout was fast and the support team was great.",
"The package arrived broken and nobody answered my emails."
]
}
Real example:
{
"results": [
{
"text": "The checkout was fast and the support team was great.",
"label": "positive",
"score": 0.9999,
"positive": 0.9999,
"negative": 0.0001
},
{
"text": "The package arrived broken and nobody answered my emails.",
"label": "negative",
"score": 0.9998,
"positive": 0.0002,
"negative": 0.9998
}
],
"model": "@cf/huggingface/distilbert-sst-2-int8"
}
{
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"label": {
"type": "string",
"enum": [
"positive",
"negative"
]
},
"score": {
"type": "number"
},
"positive": {
"type": "number"
},
"negative": {
"type": "number"
}
},
"required": [
"text",
"label",
"score",
"positive",
"negative"
],
"additionalProperties": false
}
},
"model": {
"type": "string"
}
},
"required": [
"results",
"model"
],
"additionalProperties": false
}Free schema and example: GET https://x402-gateway.blackwoodstate8.workers.dev/v1/sentiment.
OpenAPI 3.1 · llms.txt · All services