Official LangChain Integration

FluentC LangChain Tool

Official Python plugin for integrating FluentC AI Translation API with LangChain. Enable real-time and batch translation, language detection, and job polling through LangChain-compatible tools.

LangChain Integration Features

Real-time & Batch Translation

Choose between instant translations or batch processing for large content volumes.

Language Detection

Automatically detect the language of input content with confidence scoring.

Dynamic Language Selection

Dropdown menus populated with your API key's enabled languages.

Format Support

Handle both plain text and HTML content seamlessly.

Error Handling

Comprehensive error handling with continue-on-fail support.

Workflow Integration

Seamlessly integrate into any N8N automation workflow.

FluentC API Key Required

To use the FluentC LangChain tools, you'll need a valid FluentC API key with an active subscription. API keys provide access to 140+ languages and real-time translation capabilities.

Sign Up Now

Installation & Setup

Package Installation

Install the FluentC LangChain package:
# Install via pip
pip install fluentc-langchain-tool

# Or with requirements.txt
echo "fluentc-langchain-tool" >> requirements.txt
pip install -r requirements.txt
Requires Python 3.7+ and LangChain framework.

Authentication Setup

Configure your FluentC API key:

from fluentc_langchain_tool import
FluentCTranslationTool

# Initialize with API key
tool = FluentCTranslationTool( api_key="your-fluentc-api-key")

Available LangChain Tools

FluentC LangChain Tool Classes

Tool Class

Purpose

FluentCTranslationTool

Real-time or batch translation submit

FluentCLanguageDetectorTool

Detect source language from input

FluentCTranslationStatusTool

Check status of batch translation jobs

FluentCResultsTool

Poll for batch job translation result

FluentCBatchTranslationTool

One-shot batch submit + polling

Usage Examples

  • Real-Time Translation
  • Batch Translation
  • Status Checking
  • LangChain Agent
Perform real-time translation using the FluentC LangChain tool:
				
					from fluentc_langchain_tool import FluentCTranslationTool

# Initialize the translation tool
tool = FluentCTranslationTool(api_key="your-api-key")

# Perform real-time translation
response = tool.run({
    "text": "Hello, world!",
    "target_language": "fr",
    "source_language": "en",
    "mode": "realtime"
})

print(response)  # Output: "Bonjour, le monde !"

# Translation with auto-detection
response = tool.run({
    "text": "¿Cómo estás?",
    "target_language": "en",
    "mode": "realtime"
})

print(response)  # Output: "How are you?"
print("Detected source language:", response.get('detected_language', 'Unknown'))
				
			
Handle large content with batch translation and automatic polling:
				
					from fluentc_langchain_tool import FluentCBatchTranslationTool

# Initialize batch translation tool
tool = FluentCBatchTranslationTool(api_key="your-api-key")

# Translate large HTML content
large_html = """
<html>
<head><title>Welcome</title></head>
<body data-rsssl=1>
    <h1>Hello, batch world!</h1>
    <p>This is a large document that needs translation.</p>
    <p>It contains multiple paragraphs and HTML structure.</p>
</body>
</html>
"""

# Submit and automatically poll for results
result = tool.run({
    "text": large_html,
    "target_language": "de",
    "source_language": "en"
})

print("Translated HTML:")
print(result)  # Final translated output after polling

# The tool automatically:
# 1. Submits the batch job
# 2. Polls for completion using estimated_wait_seconds
# 3. Returns the final translation result
				
			
Check the status of batch translation jobs:
				
					from fluentc_langchain_tool import (
    FluentCTranslationTool, 
    FluentCTranslationStatusTool
)

# Initialize tools
translation_tool = FluentCTranslationTool(api_key="your-api-key")
status_tool = FluentCTranslationStatusTool(api_key="your-api-key")

# Submit a batch translation job
job_response = translation_tool.run({
    "text": "Large document for batch processing...",
    "target_language": "es",
    "mode": "batch"
})

job_id = job_response.get('job_id')
print(f"Batch job submitted: {job_id}")

# Check job status
status_response = status_tool.run({
    "job_id": job_id
})

print(f"Job status: {status_response}")

# Status responses include:
# - "processing": Job is still running
# - "complete": Translation finished
# - "failed": Job encountered an error
# - estimated_wait_seconds: Recommended polling interval
				
			
Integrate FluentC tools with LangChain agents for complex workflows:
				
					from langchain.agents import initialize_agent, Tool
from langchain.llms import OpenAI
from fluentc_langchain_tool import (
    FluentCTranslationTool,
    FluentCBatchTranslationTool,
    FluentCLanguageDetectorTool,
    FluentCTranslationStatusTool
)

# Initialize FluentC tools
api_key = "your-fluentc-api-key"
translation_tool = FluentCTranslationTool(api_key)
batch_tool = FluentCBatchTranslationTool(api_key)
detector_tool = FluentCLanguageDetectorTool(api_key)
status_tool = FluentCTranslationStatusTool(api_key)

# Create LangChain agent with FluentC tools
agent = initialize_agent(
    tools=[
        Tool.from_function(
            func=translation_tool.run,
            name="FluentC_Translation",
            description="Translate text in real-time or batch mode"
        ),
        Tool.from_function(
            func=batch_tool.run,
            name="FluentC_Batch_Translation",
            description="Translate large content with auto-polling"
        ),
        Tool.from_function(
            func=detector_tool.run,
            name="FluentC_Language_Detection",
            description="Detect language of input text"
        ),
        Tool.from_function(
            func=status_tool.run,
            name="FluentC_Status_Check",
            description="Check batch translation job status"
        )
    ],
    llm=OpenAI(temperature=0),
    agent="zero-shot-react-description",
    verbose=True
)

# Example agent interactions
responses = [
    "Translate 'Hello world' from English to German using FluentC.",
    "Detect the language of 'Bonjour tout le monde' and translate it to Spanish.",
    "Translate this large HTML document to French using batch processing."
]

for query in responses:
    print(f"\nQuery: {query}")
    result = agent.run(query)
    print(f"Result: {result}")
				
			

Ready to Add Translation to Your N8N Workflows?

Get started with FluentC's N8N integration today. Create your API key, install the plugin, and start building multilingual automation workflows.