Skip to main content
ClaudeWave
Skill128 repo starsupdated 2mo ago

free-translation-api

# Free Translation API Free-translation-api provides text translation across 100+ languages using the open-source LibreTranslate API without requiring authentication or incurring costs. Use this skill when translating content between languages, building multilingual documentation systems, processing international datasets, or creating translation workflows that would otherwise require expensive third-party translation services.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/besoeasy/open-skills /tmp/free-translation-api && cp -r /tmp/free-translation-api/skills/free-translation-api ~/.claude/skills/free-translation-api
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Free Translation API — LibreTranslate

Translate text between 100+ languages using free LibreTranslate instances. Open-source, privacy-respecting alternative to Google Translate API ($20/million characters).

## Why This Replaces Paid Translation APIs

**💰 Cost savings:**
- ✅ **100% free** — no API keys required for public instances
- ✅ **No rate limits** — generous limits on public instances
- ✅ **Open source** — self-hostable for unlimited usage
- ✅ **Privacy-first** — no data collection or tracking

**Perfect for AI agents that need:**
- Text translation without Google Translate API costs
- Privacy-respecting translation (no data retention)
- High volume translation without quotas
- Offline translation capability (self-hosted)

## Quick comparison

| Service | Cost | Rate limit | Privacy | API key required |
|---------|------|------------|---------|------------------|
| Google Translate API | $20/1M chars | Unlimited with payment | ❌ Tracked | ✅ Yes |
| DeepL API | $5-25/1M chars | 500k chars/month free | ❌ Tracked | ✅ Yes |
| **LibreTranslate** | **Free** | **Varies by instance** | **✅ Private** | **❌ No** |

## Skills

### translate_text

Basic text translation using LibreTranslate.

```bash
# Translate text (English to Spanish)
curl -s -X POST "https://libretranslate.com/translate" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "Hello, how are you?",
    "source": "en",
    "target": "es"
  }' | jq -r '.translatedText'

# Auto-detect source language
curl -s -X POST "https://libretranslate.com/translate" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "Bonjour le monde",
    "source": "auto",
    "target": "en"
  }' | jq -r '.translatedText'

# Translate from file
TEXT=$(cat document.txt)
curl -s -X POST "https://libretranslate.com/translate" \
  -H "Content-Type: application/json" \
  -d "{
    \"q\": \"$TEXT\",
    \"source\": \"en\",
    \"target\": \"fr\"
  }" | jq -r '.translatedText' > document_fr.txt
```

**Node.js:**

```javascript
async function translateText(text, targetLang, sourceLang = 'auto', instance = 'https://libretranslate.com') {
  const res = await fetch(`${instance}/translate`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      q: text,
      source: sourceLang,
      target: targetLang
    })
  });
  
  if (!res.ok) {
    const error = await res.text();
    throw new Error(`Translation failed: ${error}`);
  }
  
  const data = await res.json();
  return data.translatedText;
}

// Usage
// translateText('Hello world', 'es', 'en')
//   .then(translated => console.log(translated));
// Output: "Hola mundo"
```

### get_supported_languages

List all supported languages for an instance.

```bash
# Get all supported languages
curl -s "https://libretranslate.com/languages" | jq '.[] | {code: .code, name: .name}'

# Get language codes only
curl -s "https://libretranslate.com/languages" | jq -r '.[].code'

# Check if specific language is supported
curl -s "https://libretranslate.com/languages" | jq -r '.[] | select(.code == "ja") | .name'
```

**Node.js:**

```javascript
async function getSupportedLanguages(instance = 'https://libretranslate.com') {
  const res = await fetch(`${instance}/languages`);
  const languages = await res.json();
  return languages.map(lang => ({
    code: lang.code,
    name: lang.name
  }));
}

// Usage
// getSupportedLanguages().then(langs => {
//   console.log('Supported languages:', langs.length);
//   langs.slice(0, 10).forEach(l => console.log(`${l.code}: ${l.name}`));
// });
```

### detect_language

Detect the language of a text.

```bash
# Detect language
curl -s -X POST "https://libretranslate.com/detect" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "Bonjour, comment allez-vous?"
  }' | jq -r '.[0] | {language: .language, confidence: .confidence}'

# Detect language for multiple texts
curl -s -X POST "https://libretranslate.com/detect" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "Hola mundo. Cómo estás?"
  }' | jq -r '.[]'
```

**Node.js:**

```javascript
async function detectLanguage(text, instance = 'https://libretranslate.com') {
  const res = await fetch(`${instance}/detect`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ q: text })
  });
  
  if (!res.ok) {
    throw new Error('Language detection failed');
  }
  
  const results = await res.json();
  return results[0]; // Returns {language: 'en', confidence: 0.99}
}

// Usage
// detectLanguage('Hello world')
//   .then(result => console.log(`Detected: ${result.language} (${result.confidence})`));
```

### batch_translate

Translate multiple texts or paragraphs.

```bash
#!/bin/bash
# Translate multiple lines from a file
INPUT_FILE="content_en.txt"
OUTPUT_FILE="content_es.txt"
TARGET_LANG="es"

> "$OUTPUT_FILE"  # Clear output file

while IFS= read -r line; do
  if [ -n "$line" ]; then
    translated=$(curl -s -X POST "https://libretranslate.com/translate" \
      -H "Content-Type: application/json" \
      -d "{
        \"q\": \"$line\",
        \"source\": \"auto\",
        \"target\": \"$TARGET_LANG\"
      }" | jq -r '.translatedText')
    
    echo "$translated" >> "$OUTPUT_FILE"
    sleep 1  # Rate limiting
  fi
done < "$INPUT_FILE"

echo "Translation complete: $OUTPUT_FILE"
```

**Node.js:**

```javascript
async function batchTranslate(texts, targetLang, sourceLang = 'auto', delayMs = 1000) {
  const results = [];
  
  for (const text of texts) {
    try {
      const translated = await translateText(text, targetLang, sourceLang);
      results.push({ original: text, translated, success: true });
      
      // Rate limiting delay
      if (delayMs > 0) {
        await new Promise(resolve => setTimeout(resolve, delayMs));
      }
    } catch (err) {
      results.push({ original: text, translated: null, success: false, error: err.message });
    }
  }
  
  return results;
}

// Usage
// const texts = [
//   '