SRT and VTT subtitle files translator to Turkish.
npm installCreate a .env file:
OPENROUTER_API_KEY=your_openrouter_key
API_KEY=your_secret_key
PORT=3000npm startPOST /api/translate
| Header | Required | Description |
|---|---|---|
| x-api-key | Yes | API_KEY value from .env |
| Content-Type | Yes | multipart/form-data |
| Field | Type | Description |
|---|---|---|
| file | File | .srt or .vtt file |
curl -X POST http://localhost:3000/api/translate \
-H "x-api-key: your_secret_key" \
-F "file=@subtitle.vtt"const formData = new FormData();
formData.append('file', file);
const response = await fetch('http://localhost:3000/api/translate', {
method: 'POST',
headers: {
'x-api-key': 'your_secret_key'
},
body: formData
});
const blob = await response.blob();- Status: 200
- Content-Type: text/plain
- Content-Disposition: attachment; filename="original_filename.vtt"
- Body: Translated subtitle content
{
"error": {
"code": 1001,
"message": "File not uploaded"
}
}| Code | Description |
|---|---|
| 1001 | File not uploaded |
| 1002 | Unsupported format |
| 1003 | File could not be read |
| 1004 | File size too large (max 5MB) |
| 2001 | API key missing |
| 2002 | API key invalid |
| 3001 | OpenRouter API error |
| 3002 | Model did not respond |
| 3004 | Rate limit exceeded |
- Push to GitHub
- Import on Vercel
- Add environment variables:
OPENROUTER_API_KEYAPI_KEY
- Deploy
npm i -g vercel
vercel- Max file size: 5MB
- Supported formats: .srt, .vtt
You can run the project in an isolated manner with Docker and test it using the aiceviri-api.local domain name.
- Create your
.envfile:
cp .env.example .envAdd the required API keys. You can allow requests from external sources by adding the CORS_ORIGINS variable:
CORS_ORIGINS=http://localhost:3000,https://aiceviri-api.local-
Add the domain to your computer's
hostsfile:- Linux/Mac: Open
/etc/hostswithsudo nano /etc/hosts. - Windows: Open
C:\Windows\System32\drivers\etc\hostsas administrator.
Add this line:
127.0.0.1 aiceviri-api.local - Linux/Mac: Open
-
Start with Docker Compose:
docker-compose up -dYour API will now be available at https://aiceviri-api.local/api/translate. Caddy will automatically create its own SSL certificate (tls internal) for local development. If your browser shows a security warning, you can proceed from the advanced tab.