agentsvc.io

services / language-detect

textoperational · 1 ms

Language Detection

Detect the language of a text (80+ languages) with ISO 639-1 and 639-3 codes, confidence, a reliability flag and the top candidates. Runs locally, nothing is stored. Params: text (required, up to 20,000 characters), top (number of candidates, default 3).

Run free trial ↗3 free calls per day with the example input. Paid: $0.002 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/language-detect", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"text":"Bonjour, je voudrais réserver une table pour deux personnes ce soir."}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription
text *string
topinteger = 3

Output

FieldTypeDescription
languagestring
iso639_1string
iso639_3string
confidencenumber
reliableboolean
candidatesarray
charactersinteger

Example response (data)

{
  "language": "French",
  "iso639_1": "fr",
  "iso639_3": "fra",
  "confidence": 0.878,
  "reliable": true,
  "candidates": [
    {
      "iso639_3": "fra",
      "iso639_1": "fr",
      "name": "French",
      "score": 1
    },
    {
      "iso639_3": "spa",
      "iso639_1": "es",
      "name": "Spanish",
      "score": 0.622
    }
  ],
  "characters": 68
}