#!/usr/bin/env python3 """Probe which OpenAI chat parameters gpt-5.4-mini accepts. Reads the key from the environment and never prints it. """ import json import os import sys import urllib.error import urllib.request KEY = os.environ.get("OPENAI_API_KEY", "") MODEL = os.environ.get("FORGEWAY_CLOUD_MODEL", "gpt-5.4-mini") if not KEY: sys.exit("OPENAI_API_KEY not present in the environment") CASES = { "max_completion_tokens only": {"max_completion_tokens": 16}, "max_tokens only": {"max_tokens": 16}, "temperature=0": {"max_completion_tokens": 16, "temperature": 0}, "temperature=1": {"max_completion_tokens": 16, "temperature": 1}, "top_p=0.9": {"max_completion_tokens": 16, "top_p": 0.9}, "stream=true": {"max_completion_tokens": 16, "stream": True}, } for label, extra in CASES.items(): body = {"model": MODEL, "messages": [{"role": "user", "content": "say PONG"}], **extra} req = urllib.request.Request( "https://api.openai.com/v1/chat/completions", data=json.dumps(body).encode(), headers={"Content-Type": "application/json", "Authorization": f"Bearer {KEY}"}, method="POST", ) try: with urllib.request.urlopen(req, timeout=60) as resp: print(f"{label:28s} -> {resp.status} OK") except urllib.error.HTTPError as exc: detail = exc.read().decode("utf-8", "replace") try: detail = json.loads(detail)["error"]["message"] except Exception: detail = detail[:160] print(f"{label:28s} -> {exc.code} {detail}") except Exception as exc: # noqa: BLE001 print(f"{label:28s} -> ERROR {type(exc).__name__}: {exc}")