Skip to content

missuo/openai-translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Workflow Go Version Go Report Maintainability GitHub License Docker Pulls Releases FOSSA Status

Features

  • Setting up an API Key once allows it to be called from anywhere.
  • Unlimited requests, billed by usage.
  • Deployed on overseas servers, it can bypass the Great Firewall (GFW).

Usage

Request Parameters

  • text: string
  • source_lang: string
  • target_lang: string

Response

{
  "code": 200,
  "cost": 0.000013,
  "data": "Hello world.",
  "source_lang": "ZH",
  "target_lang": "EN",
  "token_consumed": 10
}

Docker Compose

mkdir openai-translate && cd openai-translate
wget https://raw.githubusercontent.com/missuo/openai-translate/main/compose.yaml
nano compose.yaml # Modify OPENAI_KEY
docker compose up -d

Docker

# ghcr.io
docker run -itd -p 23333:23333 -e OPENAI_KEY=YOUR_API_KEY ghcr.io/missuo/openai-translate:latest
# dockerhub
docker run -itd -p 23333:23333 -e OPENAI_KEY=YOUR_API_KEY missuo/openai-translate:latest

Setup on Bob App

Important

This project is fully compatible with the bob-plugin-deeplx plugin.

  1. Install bob-plugin-deeplx on Bob.

  2. Setup the API. (If you use Brew to install locally you can skip this step) c5c19dd89df6fae1a256d

Use in Python

import httpx, json

openai_api = "http://127.0.0.1:23333/translate"

data = {
	"text": "Hello World",
	"source_lang": "EN",
	"target_lang": "ZH"
}

post_data = json.dumps(data)
r = httpx.post(url = openai_api, data = post_data).text
print(r)

TODO

  • Support GPT-4, GPT-4-Turbo
  • Support set access token
  • Maximum request per second limit

License

FOSSA Status