Rspamd can send emails to OpenAI’s GPT API and get the response.

  • Obvious spam and ham will not be sent to prevent wasting the API quota
  • You need a GPT API key to use this plugin (or your own Ollama server)

Configuration

Create /etc/rspamd/local.d/gpt.conf and add the following lines.

enabled = true;
api_key = "<apikey>";
model = "gpt-5.4-mini";
autolearn = true
reason_header = "X-GPT-Reason";

# Add this for testing
allow_ham = true;
  • Delete autolearn = true if you feel the GPT results are not very reliable.

Add the following line to /etc/rspamd/local.d/options.inc to extend the timeout to wait for the GPT API response.

# 20 seconds should be enough though...
task_timeout = 30s;

Reload Rspamd.

sudo systemctl reload rspamd

Test GPT plugin

Send a legitimate test mail and check the headers. It should have the X-GPT-Reason header with the response from GPT API and GPT_HAM symbol under the X-Spamd-Result header.

Remember to delete the allow_ham = true; line after testing to avoid wasting the API quota.