Openai Translate Save

Build your own OpenAI translation API

Project README

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

Open Source Agenda is not affiliated with "Openai Translate" Project. README Source: missuo/openai-translate
Stars
56
Open Issues
0
Last Commit
3 months ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating