Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

Suppress OpenAI SDK debug payload logs (#1512)

Ali Khokhar23071a6cba8d
diff --git a/pyproject.toml b/pyproject.toml
index 86ed3dce..7d72ee7e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "free-claude-code"
-version = "5.13.5"
+version = "5.13.6"
description = "Local proxy connecting coding agents to OpenAI-compatible AI providers"
readme = "README.md"
requires-python = ">=3.14.0"
diff --git a/src/free_claude_code/config/logging_config.py b/src/free_claude_code/config/logging_config.py
index 2d1b4ac1..d07880e6 100644
--- a/src/free_claude_code/config/logging_config.py
+++ b/src/free_claude_code/config/logging_config.py
@@ -21,6 +21,7 @@ _current_verbose: bool | None = None
_sink_id: int | None = None
_THIRD_PARTY_LOGGERS = (
+ "openai",
"httpx",
"httpcore",
"httpcore.http11",
@@ -151,8 +152,8 @@ def configure_logging(
On verbosity change alone, updates only the third-party logger levels.
Use force=True to reconfigure from scratch.
- When ``verbose_third_party`` is false, noisy HTTP and Telegram loggers are
- capped at WARNING unless explicitly configured otherwise.
+ When ``verbose_third_party`` is false, managed noisy third-party loggers
+ are capped at WARNING unless explicitly configured otherwise.
"""
global _configured, _current_path, _current_level, _current_verbose, _sink_id
diff --git a/tests/config/test_logging_config.py b/tests/config/test_logging_config.py
index 66ed40b6..660bc04f 100644
--- a/tests/config/test_logging_config.py
+++ b/tests/config/test_logging_config.py
@@ -95,19 +95,50 @@ def test_bearer_substring_redacted_in_log_file(tmp_path) -> None:
assert "Bearer" in text
-def test_httpx_logger_quieted_when_not_verbose_third_party(tmp_path) -> None:
+def test_noisy_third_party_loggers_quieted_when_not_verbose(tmp_path) -> None:
log_file = str(tmp_path / "quiet.log")
configure_logging(log_file, force=True, verbose_third_party=False)
+ assert logging.getLogger("openai").level >= logging.WARNING
+ assert (
+ logging.getLogger("openai._base_client").getEffectiveLevel() >= logging.WARNING
+ )
assert logging.getLogger("httpx").level >= logging.WARNING
assert logging.getLogger("httpcore").level >= logging.WARNING
-def test_httpx_resets_to_notset_when_verbose_third_party(tmp_path) -> None:
+def test_noisy_third_party_loggers_reset_when_verbose(tmp_path) -> None:
log_file = str(tmp_path / "verbose.log")
configure_logging(log_file, force=True, verbose_third_party=True)
+ assert logging.getLogger("openai").level == logging.NOTSET
assert logging.getLogger("httpx").level == logging.NOTSET
+def test_openai_request_payload_debug_requires_verbose_third_party(tmp_path) -> None:
+ log_file = tmp_path / "openai.log"
+ marker = "Request options: sensitive-prompt"
+ openai_logger = logging.getLogger("openai._base_client")
+
+ configure_logging(
+ log_file,
+ force=True,
+ level="DEBUG",
+ verbose_third_party=False,
+ )
+ openai_logger.debug(marker)
+ logger.complete()
+ assert marker not in log_file.read_text(encoding="utf-8")
+
+ configure_logging(
+ log_file,
+ force=True,
+ level="DEBUG",
+ verbose_third_party=True,
+ )
+ openai_logger.debug(marker)
+ logger.complete()
+ assert marker in log_file.read_text(encoding="utf-8")
+
+
def test_configure_logging_respects_level(tmp_path) -> None:
"""INFO level suppresses DEBUG messages from the file sink."""
log_file = str(tmp_path / "level.log")
@@ -195,12 +226,14 @@ def test_configure_logging_updates_verbosity_on_same_level(tmp_path) -> None:
# Start with verbosity off (third-party loggers at WARNING)
configure_logging(log_file, force=True, level="DEBUG", verbose_third_party=False)
+ assert logging.getLogger("openai").level >= logging.WARNING
assert logging.getLogger("httpx").level >= logging.WARNING
assert logging.getLogger("httpcore").level >= logging.WARNING
assert logging.getLogger("telegram").level >= logging.WARNING
# Restart with same level but verbosity on
configure_logging(log_file, level="DEBUG", verbose_third_party=True)
+ assert logging.getLogger("openai").level == logging.NOTSET
assert logging.getLogger("httpx").level == logging.NOTSET
assert logging.getLogger("httpcore").level == logging.NOTSET
assert logging.getLogger("telegram").level == logging.NOTSET
diff --git a/uv.lock b/uv.lock
index bb974ceb..ad9f9f44 100644
--- a/uv.lock
+++ b/uv.lock
@@ -607,7 +607,7 @@ wheels = [
[[package]]
name = "free-claude-code"
-version = "5.13.5"
+version = "5.13.6"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },