Skip to content

tombailey/translation-api

Repository files navigation

translation-api

Introduction

This is a simple translation API written in Rust.

Getting started

FROM tombailey256/translation-api:0.0.0

ENV PORT = 8080

See Docker Hub for the latest release tags: https://hub.docker.com/r/tombailey256/translation-api

Rest API

Translate

curl -X POST -H "Content-Type: application/json" http://localhost:8080/translate -d '[{ "source": "en", "target": "fr", "input": "Hello" }]'
# 200 OK
# [{ "source": "en", "output": "Bonjour" }]

Providers

Claude

Uses a Claude model for translation.

export CLAUDE_API_KEY="..."
export CLAUDE_API_VERSION="2023-06-01"
export CLAUDE_MODEL="claude-3-sonnet-20240229"
export CLAUDE_MAX_PARALLEL_REQUESTS="3"

DeepL

Uses DeepL for translation.

export DEEPL_API="https://api-free.deepl.com/v2"
export DEEPL_AUTHENTICATION_KEY="..."
export DEEPL_MAX_PARALLEL_REQUESTS="3"

OpenAI

Uses an OpenAI model for translation.

export OPENAI_API_KEY="..."
export OPENAI_MODEL="gpt-4-turbo-preview"
export OPENAI_MAX_PARALLEL_REQUESTS="3"

Health check

A built-in health check endpoint (/health) confirms that the translation-api is working correctly. Where possible, it will verify connectivity with the specified provider.