https://github.com/xjasonlyu/openai-translator
Go translation library powered by the OpenAI API
https://github.com/xjasonlyu/openai-translator
Last synced: 6 months ago
JSON representation
Go translation library powered by the OpenAI API
- Host: GitHub
- URL: https://github.com/xjasonlyu/openai-translator
- Owner: xjasonlyu
- License: mit
- Created: 2025-04-07T21:35:14.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-04-09T04:10:55.000Z (6 months ago)
- Last Synced: 2025-04-23T22:17:27.261Z (6 months ago)
- Language: Go
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenAI Translator
A Golang translation library compatible with the [OpenAI API](https://platform.openai.com/docs/overview).
## Installation
Using the Go command, from inside your project:
```shell
go get -u github.com/xjasonlyu/openai-translator
```## Usage
```go
package mainimport (
"fmt"
"log"
"os"openai "github.com/xjasonlyu/openai-translator"
)func main() {
apiKey := os.Getenv("OPENAI_API_KEY")
apiURL := os.Getenv("OPENAI_API_URL")translator := openai.NewTranslator(
apiKey,
openai.WithBaseURL(apiURL),
)text, err := translator.TranslateText("Hello, world!", "ZH")
if err != nil {
log.Fatal(err)
}fmt.Println(text) // "你好,世界!"
}```
## Credits
- [zijiren233/openai-translator](https://github.com/zijiren233/openai-translator)
## License
This project is open-sourced under the MIT license. See the [LICENSE](LICENSE) file for more details.