**Implementation Plan: Fix `deepseek-v4-pro` 400 Bad Request** **Root Cause Hypothesis** The upstream DeepSeek API for `V4-Pro` expects an explicit `thinking` parameter in the request body. When absent, the API returns HTTP 400. The gateway forwards the client payload verbatim (except for `stream`/`stream_options`), so clients that omit `thinking` trigger the error. `V4-Flash` tolerates this omission. **Change Location** File: `devplacepy/services/openai_gateway/gateway.py` (or equivalent chat forwarding module). Specifically, the function that prepares the payload sent to `https://api.deepseek.com/chat/completions`. **Step 1 – Add sanitization function** Insert a helper function, e.g. `_sanitize_deepseek_v4_pro(payload: dict) -> dict`, that: - If `payload["model"]` equals `"deepseek-v4-pro"` (or the route’s target model matches), and - The `thinking` key is missing from `payload`, - Then add `thinking: {"type": "disabled"}` to the payload. Return the (possibly modified) payload. **Step 2 – Apply sanitization in the forwarding pipeline** Locate the point where the payload is finalised before the upstream HTTP call. After the existing `stream=false` and `stream_options` stripping, call `_sanitize_deepseek_v4_pro(payload)` and use its return value as the final payload. **Step 3 – Unit test** In `tests/unit/services/openai_gateway/routing.py` (or a new test file), add a test that: - Assembles a sample request body without `thinking`. - Passes it through the forwarding logic (or directly calls the sanitization function) with `model: "deepseek-v4-pro"`. - Asserts the output contains `thinking: {"type": "disabled"}`. - Also assert that a request with `thinking` already set is left unchanged, and that models other than `deepseek-v4-pro` are unaffected. **Step 4 – Verify existing tests** Run `pip install -e '.[dev]' -q && make test-unit`. All tests must pass. **Step 5 – Lint** Run `pip install -q ruff && ruff check .`. No violations. --- **Definition of Done** - [ ] The helper function `_sanitize_deepseek_v4_pro` is added in the appropriate gateway module and correctly injects `thinking: {"type": "disabled"}` for requests targeting `deepseek-v4-pro` when the field is missing. - [ ] The forwarding pipeline calls this function before the upstream request. - [ ] A dedicated unit test covers the sanitization behaviour (and non‑behaviour for other models). - [ ] `make test-unit` exits with code 0 (all unit tests pass). - [ ] `ruff check .` reports `All checks passed!`.