From 42a93f53196fdf674db8e3277fcf251059a298ad Mon Sep 17 00:00:00 2001 From: G-Fourteen Date: Fri, 31 Oct 2025 17:28:58 -0600 Subject: [PATCH] Fix Pollinations test headers --- tests/test_text_generation.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/test_text_generation.py b/tests/test_text_generation.py index 2f445a6..bd9c83f 100644 --- a/tests/test_text_generation.py +++ b/tests/test_text_generation.py @@ -10,6 +10,17 @@ TEST_NAME = "Pollinations Unity text response" API_URL = "https://text.pollinations.ai/openai" +REQUEST_HEADERS = { + "Content-Type": "application/json", + # Pollinations expects requests to identify the Unity AI Lab origin when + # using the OpenAI-compatible endpoint. Without these headers the service + # replies with HTTP 402 (Payment Required) even though the public endpoint + # is free to use. Supplying Origin/Referer makes the intent explicit and + # avoids the erroneous billing prompt. + "Origin": "https://unityailab.com", + "Referer": "https://unityailab.com/", + "User-Agent": "ShittyVoiceTest/1.0", +} def run() -> Dict[str, Any]: @@ -24,7 +35,12 @@ def run() -> Dict[str, Any]: } try: - response = requests.post(API_URL, json=payload, timeout=20) + response = requests.post( + API_URL, + json=payload, + headers=REQUEST_HEADERS, + timeout=20, + ) duration = time.perf_counter() - start response.raise_for_status() data = response.json()