Skip to content

fix(client): send health_check and proxy_request to root-level routes when base_url ends in /v1 - #136

Merged
edenreich merged 1 commit into
mainfrom
fix/issue-133
Sep 25, 2026
Merged

edenreich merged 1 commit into
mainfrom
fix/issue-133

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Resolves #133

Summary

health_check() and proxy_request() appended their route to base_url, so a client built the way every README example builds it (InferenceGatewayClient("http://localhost:8080/v1")) requested /v1/health and /v1/proxy/{provider}/... - paths the gateway does not serve, since both routes are registered at the root (openapi.yaml attaches the Health and Proxy tags to the unversioned server). Both methods now build their URLs from the existing _root_url helper, the same way mcp_jsonrpc() and get_mcp_protected_resource_metadata() already do, so a /v1 suffix is stripped for these root-level routes.

Changes

  • proxy_request() now builds the proxy URL from self._root_url instead of self.base_url, and its docstring notes the route lives at the gateway root.
  • health_check() now checks f"{self._root_url}/health" instead of f"{self.base_url}/health", with the same docstring note.
  • Added regression tests test_health_check_with_v1_base_url and test_proxy_request_with_v1_base_url, mirroring the existing mock style: a client built with http://test-api/v1 must hit http://test-api/health and http://test-api/proxy/openai/v1/models respectively. The old tests passed only because they built a client without /v1.

Verification

  • task test: 44 tests collected, 43 passed, 1 xfailed (pre-existing, unrelated).
  • task lint: black, isort, and mypy all clean.

No docs ticket: this is a bug fix that makes the SDK behave as the existing README "Health Check" and "Proxy Requests" examples already document; the docs themselves need no change. No downstream impact: python-sdk only, no schema or gateway changes.

health_check() and proxy_request() appended their path to base_url, so a client built as documented (base_url ending in /v1) requested /v1/health and /v1/proxy/... which the gateway does not serve. Both routes live at the root, so build their URLs from the existing _root_url helper, the same way mcp_jsonrpc() and get_mcp_protected_resource_metadata() do. Adds regression tests for both methods with a /v1 base_url.
@inference-gateway-maintainer
inference-gateway-maintainer Bot marked this pull request as ready for review September 25, 2026 22:52
@edenreich
edenreich merged commit ec782ca into main Sep 25, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-133 branch September 25, 2026 22:53
inference-gateway-releaser Bot added a commit that referenced this pull request Sep 26, 2026
## [0.21.1](v0.21.0...v0.21.1) (2026-09-26)

### 🐛 Bug Fixes

* **client:** carry HTTP status and error body into InferenceGatewayAPIError ([#139](#139)) ([d58a54f](d58a54f))
* **client:** close requests Session in close() and apply timeout to streaming calls ([#138](#138)) ([4a1e48f](4a1e48f))
* **client:** route health_check and proxy_request to root-level routes ([#136](#136)) ([ec782ca](ec782ca))

### 📚 Documentation

* **readme:** correct MCP_ENABLED env var, provider list, vision reference, and images example ([#137](#137)) ([8cc2ef6](8cc2ef6))
* **readme:** document streaming error behavior parity ([#140](#140)) ([23a1d69](23a1d69))

### 🔧 Miscellaneous

* **deps:** bump claude-code 2.1.278 -> 2.1.280 ([#130](#130)) ([2a73e16](2a73e16))
* **deps:** bump infer CLI v0.205.3 -> v0.208.0 ([#131](#131)) ([703f184](703f184))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.21.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] health_check() and proxy_request() call /v1/health and /v1/proxy when base_url ends in /v1

1 participant