Metadata-Version: 2.4
Name: gettext-translator-chatgpt
Version: 0.1.0
Summary: OpenAI ChatGPT backend for gettext-translator
Author-email: Rodolfo González González <code@rodolfo.gg>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/rgglez/gettext-translator
Project-URL: Issues, https://github.com/rgglez/gettext-translator/issues
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: gettext-translator-service<0.2,>=0.1
Requires-Dist: openai<3,>=2

# gettext-translator-chatgpt

ChatGPT API backend for [gettext-translator](https://github.com/rgglez/gettext-translator).

## Usage from gettext-translator

```bash
gettext-translator --backend chatgpt --config sample-chatgpt.yaml --src en --dst fr_CA --po /path/to/example/messages.po
```

This command translates the `messages.po` file from English into Canadian French (fr_CA), using the provided OpenAI API key, using the `gpt-4o-mini` model processing 100 translations per batch. Very good results are produced by this model, which is a cheap one. See the [chatgpt-sample.yaml](chatgpt-sample.yaml) configuration file for the example.

## Configuration

* `apikey`
  - Your OpenAI ChatGPT API key.
  - Or, if you prefix the string with "env:", the value of the environment variable with the same name will be used. Example: apikey="env:MY_OPENAI_API_KEY" and then in the shell ```export MY_OPENAI_API_KEY="sk-..."```.
* `model` the model you want to use. See the Notes below.

## Installation

```bash
pip install "gettext-translator[chatgpt]"
```

## Notes

- You can find the name of the OpenAI ChatGPT models and their pricing [here](https://openai.com/api/pricing/).
- Of course, you need an [OpenAI API key](https://platform.openai.com/settings/organization/api-keys).

## License

Copyright (C) 2026 Rodolfo González González.

Licensed under [GPL 3.0](https://www.gnu.org/licenses/gpl-3.0.html).
