REST API Free Tier Multilingual Detection

prompt to Text API

Detect language with a single API call. Built for developers who need consistent outputs, configurable generation settings, and optional response variants at scale.

Why Use This API

AI Language Detection

Advanced language identification models tuned for short and long text. Accurately detects dominant language and likely alternatives.

Probability Scoring

Returns confidence-style probabilities for detected languages so you can apply thresholds in production workflows.

Language Candidates

Optionally includes ranked language candidates and probabilities for multilingual or ambiguous text.

Multilingual Detection

Detect language across short snippets or long documents in one request. Useful for routing, localization, and analytics.

Quick Start

Start detecting language in under a minute. Here's how:

  1. Get your API keySign up free to receive your key
  2. Send a request — POST a text prompt to the endpoint
  3. Get the result — Receive detected language results as JSON responses
curl -X POST https://precisioncounter.com/api/v1/language-detection \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "prompt=Bonjour, comment allez-vous aujourd'hui?"
import requests

response = requests.post(
    "https://precisioncounter.com/api/v1/language-detection",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    files={"prompt": open("sample.png", "rb")}
)

data = response.json()
for text in data["text"]:
    print(f"{text['name']} ({text['confidence']:.0%})")
const fs = require("fs");
const FormData = require("form-data");

const form = new FormData();
form.append("prompt", fs.createReadStream("sample.png"));

const response = await fetch(
  "https://precisioncounter.com/api/v1/language-detection",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      ...form.getHeaders()
    },
    body: form
  }
);

const data = await response.json();
data.text.forEach(f => console.log(`${f.name} (${f.confidence})`));

API Reference

Base URL

https://precisioncounter.com/api/v1

Authentication

All requests require an API key passed in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Detect language

POST /api/v1/language-detection

Generates text from an input prompt and returns structured generation results as JSON.

Request Parameters

Parameter Type Description
prompt required file Input text to analyze for language detection. Can be a sentence, paragraph, or full document excerpt.
max_candidates optional integer Max number of likely language candidates to return. Default: 5. Range: 1-20.
include_probabilities optional boolean Include alternate generated variants in the response. Default: true.

Response

200 OK — Returns detected language data as JSON.

{
  "text": [
    {
      "name": "person",
      "confidence": 0.94,
      "category": "person",
      "box": {
        "x": 124,
        "y": 52,
        "width": 300,
        "height": 540
      }
    }
  ],
  "prompt_width": 1280,
  "prompt_height": 720,
  "processing_time_ms": 450
}

Response Headers

Header Value
Content-Type application/json
X-Credits-Remaining Number of API credits remaining
X-Processing-Time Processing time in milliseconds

Code Examples

Full Examples (with error handling)

curl -X POST https://precisioncounter.com/api/v1/language-detection \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "prompt=Bonjour, comment allez-vous aujourd'hui?" \
  -F "max_candidates=5" \
  -F "include_probabilities=true"
import requests
import sys

API_KEY = "YOUR_API_KEY"
API_URL = "https://precisioncounter.com/api/v1/language-detection"

def detect_text(input_path, max_candidates=5):
    """Detect language from an prompt file."""
    with open(input_path, "rb") as img:
        response = requests.post(
            API_URL,
            headers={"Authorization": f"Bearer {API_KEY}"},
            files={"prompt": img},
            data={"max_candidates": max_candidates, "include_probabilities": "true"}
        )

    if response.status_code == 200:
        data = response.json()
        for text in data["text"]:
            print(f"{text['name']} - {text['confidence']:.0%} confidence")
            print(f"  Category: {text['category']}")
            if text.get("box"):
              print(f"  Box: {text['box']}")
        print(f"Credits remaining: {response.headers.get('X-Credits-Remaining')}")
    else:
        print(f"Error {response.status_code}: {response.json()['error']}")

detect_text("sample.png")
const fs = require("fs");
const FormData = require("form-data");
const fetch = require("node-fetch");

const API_KEY = "YOUR_API_KEY";
const API_URL = "https://precisioncounter.com/api/v1/language-detection";

async function detecttext(inputPath, maxResults = 5) {
  const form = new FormData();
  form.append("prompt", fs.createReadStream(inputPath));
  form.append("max_candidates", String(maxResults));
  form.append("include_probabilities", "true");

  const response = await fetch(API_URL, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      ...form.getHeaders()
    },
    body: form
  });

  if (response.ok) {
    const data = await response.json();
    data.text.forEach(text => {
      console.log(`${text.name} - ${(text.confidence * 100).toFixed(0)}%`);
      console.log(`  Category: ${text.category}`);
      if (text.box) console.log(`  Box: ${JSON.stringify(text.box)}`);
    });
    console.log(`Credits: ${response.headers.get("x-credits-remaining")}`);
  } else {
    const error = await response.json();
    console.error(`Error ${response.status}: ${error.error}`);
  }
}

detecttext("sample.png");
<?php
$api_key = "YOUR_API_KEY";
$url = "https://precisioncounter.com/api/v1/language-detection";

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer $api_key"
    ],
    CURLOPT_POSTFIELDS => [
        "prompt" => new CURLFile("sample.png"),
        "max_candidates" => "5",
        "include_probabilities" => "true"
    ]
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $data = json_decode($response, true);
    foreach ($data["text"] as $text) {
        echo $text["name"] . " - " . ($text["confidence"] * 100) . "% confidence\n";
        echo "  Category: " . $text["category"] . "\n";
        if (isset($text["box"])) {
          echo "  Box: " . json_encode($text["box"]) . "\n";
        }
    }
} else {
    echo "Error $httpCode: $response\n";
}
?>
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
    "os"
)

type textResult struct {
    Name       string   `json:"name"`
    Confidence float64  `json:"confidence"`
    Category   string   `json:"category"`
  Box        map[string]int `json:"box"`
}

type Response struct {
  text        []textResult `json:"text"`
  promptWidth     int            `json:"prompt_width"`
  promptHeight    int            `json:"prompt_height"`
  ProcessingTime int            `json:"processing_time_ms"`
}

func detecttext(inputPath string) error {
    file, _ := os.Open(inputPath)
    defer file.Close()

    body := &bytes.Buffer{}
    writer := multipart.NewWriter(body)
    part, _ := writer.CreateFormFile("prompt", inputPath)
    io.Copy(part, file)
    writer.WriteField("max_candidates", "5")
    writer.Close()

    req, _ := http.NewRequest("POST",
        "https://precisioncounter.com/api/v1/language-detection", body)
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Set("Content-Type", writer.FormDataContentType())

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return err
    }
    defer resp.Body.Close()

    if resp.StatusCode == 200 {
        var result Response
        json.NewDecoder(resp.Body).Decode(&result)
        for _, text := range result.text {
            fmt.Printf("%s - %.0f%% confidence\n", text.Name, text.Confidence*100)
        }
    }
    return nil
}

func main() {
    detecttext("sample.png")
}
require "net/http"
require "uri"
require "json"

api_key = "YOUR_API_KEY"
uri = URI("https://precisioncounter.com/api/v1/language-detection")

form_data = [
  ["prompt", File.open("sample.png", "rb")],
  ["max_candidates", "5"],
  ["include_probabilities", "true"]
]

req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{api_key}"
req.set_form(form_data, "multipart/form-data")

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(req)
end

if res.code == "200"
  data = JSON.parse(res.body)
  data["text"].each do |text|
    puts "#{text['name']} - #{(text['confidence'] * 100).round}% confidence"
    puts "  Category: #{text['category']}"
    puts "  Box: #{text['box']}" if text['box']
  end
else
  puts "Error #{res.code}: #{res.body}"
end
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

using var form = new MultipartFormDataContent();
var promptContent = new ByteArrayContent(File.ReadAllBytes("sample.png"));
promptContent.Headers.ContentType = new("prompt/png");
form.Add(promptContent, "prompt", "sample.png");
form.Add(new StringContent("5"), "max_candidates");
form.Add(new StringContent("true"), "include_probabilities");

var response = await client.PostAsync(
    "https://precisioncounter.com/api/v1/language-detection", form);

if (response.IsSuccessStatusCode)
{
    var json = await response.Content.ReadAsStringAsync();
    var data = JsonSerializer.Deserialize<JsonElement>(json);
    foreach (var text in data.GetProperty("text").EnumerateArray())
    {
        Console.WriteLine($"{text.GetProperty("name")} - {text.GetProperty("confidence")}");
    }
}

Error Handling

The API returns standard HTTP status codes with JSON error bodies:

Status Meaning Description
200 Success Language detected successfully. Response body contains JSON with language data.
400 Bad Request Missing prompt file, unsupported format, or file too large.
401 Unauthorized Missing or invalid API key.
429 Rate Limited Too many requests. Wait and retry with exponential backoff.
500 Server Error Internal processing error. Retry the request.

Error Response Format

{
  "error": "Invalid file format. Accepted: png, jpg, jpeg, webp",
  "code": "INVALID_FORMAT",
  "status": 400
}

Rate Limits

Plan Requests / Minute Max File Size Max Resolution
Free 10 10 MB 4096 x 4096 px
Pro 60 25 MB 8192 x 8192 px

Rate limit headers are included in every response:

X-RateLimit-Limit: 10
X-RateLimit-Remaining: 7
X-RateLimit-Reset: 1708646400

Use Cases

  • Design asset management
  • Brand consistency checking
  • Web scraping prompt to Text
  • Accessibility compliance
  • Print production
  • prompt analysis research
  • Design tool plugins
  • language routing verification

Pricing

Free to Start

Get free API credits when you sign up. No credit card required.

Frequently Asked Questions

What prompt formats does the Language Detection API support?
The API accepts plain text prompts and returns generated text in a structured JSON response.
Is the Language Detection API free?
Yes. You get free API calls to try the service when you sign up. No credit card is required to get started.
How accurate is language detection?
The API uses modern language identification models. Accuracy is strongest with sufficient text context and clear input, and may be lower on very short fragments.
Can the API detect mixed-language text?
Yes. The API can detect dominant language and return additional likely candidates for mixed or ambiguous input. Use the max_candidates parameter to control how many candidates are returned.
Does the API return language probabilities?
Yes. By default, the API can include probability scores for returned language candidates. You can disable this with the include_probabilities parameter set to false.
What information does the API return for each result?
The API returns detected language code, language name, optional candidate probabilities, and processing metadata.
Does the API store my prompts?
No. prompts are processed in memory and immediately discarded after the response is sent. We do not store, log, or share any uploaded prompts.