Skip to content

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

Closed

Description

Summary

Every README example builds the client as InferenceGatewayClient("http://localhost:8080/v1"), and the constructor docstring says base_url "should include /v1" (inference_gateway/client.py line 112). The README "Health Check" and "Proxy Requests" sections call client.health_check() and client.proxy_request(provider="openai", path="/v1/models", method="GET") on that client. Both methods append their route to base_url unchanged:

  • health_check() (line 1255): f"{self.base_url}/health" -> http://localhost:8080/v1/health
  • proxy_request() (line 1234): f"{self.base_url}/proxy/{provider_value}/..." -> http://localhost:8080/v1/proxy/openai/v1/models

The gateway serves both routes at the root, not under /v1. openapi.yaml (lines 17-23) puts the Health and Proxy tags on the unversioned http://localhost:8080 server ("Default server without version prefix for healthcheck and proxy"). The gateway's cmd/gateway/main.go registers GET /health and ANY /proxy/:provider/*path on the root router, outside its /v1 group.

The SDK already handles this for the other root-level routes: mcp_jsonrpc() and get_mcp_protected_resource_metadata() use the _root_url property (lines 221-224) to strip a trailing /v1. health_check() and proxy_request() do not use it. The unit tests pass only because test_health_check and test_proxy_request build a separate client without /v1 (InferenceGatewayClient("http://test-api")). The README never tells users to do that.

Steps to Reproduce

  1. Run an Inference Gateway on localhost:8080.
  2. Create the client as the README does: client = InferenceGatewayClient("http://localhost:8080/v1").
  3. Call client.health_check() (README "Health Check").
  4. Call client.proxy_request(provider="openai", path="/v1/models", method="GET") (README "Proxy Requests").

Expected Behavior

Both methods target the root-level routes (GET /health and /proxy/{provider}/{path}) even when base_url ends in /v1, as mcp_jsonrpc() does through _root_url. health_check() returns True for a healthy gateway and proxy_request() returns the provider response.

Actual Behavior

The SDK requests GET /v1/health and GET /v1/proxy/openai/v1/models. The gateway does not route either path, so both calls get an HTTP error. health_check() swallows the error and returns False, so the README example prints "API is unavailable" for a healthy gateway. proxy_request() raises InferenceGatewayAPIError.

Activity

  1. edenreich commented on Sep 25, 2026

    @edenreich
    Contributor

    @infer Can you fix this?

  2. inference-gateway-maintainer commented on Sep 25, 2026

    @inference-gateway-maintainer
    ContributorAuthor

    Model: ollama_cloud/glm-5.3-flash · View Job

    Todos

    Pull Request

    #136

    ✅ Infer Result: Success

    Fixed. PR #136 is ready for review: #136

    Summary

    health_check() and proxy_request() were appending their route directly 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. Both methods now build their URLs from the existing _root_url helper, which strips a trailing /v1, exactly the way mcp_jsonrpc() and get_mcp_protected_resource_metadata() already handle root-level routes.

    Changes

    • inference_gateway/client.py: proxy_request() builds the proxy URL from self._root_url; health_check() checks f"{self._root_url}/health"; both docstrings now note the routes live at the gateway root and that a /v1 suffix is stripped.
    • tests/test_client.py: added test_health_check_with_v1_base_url and test_proxy_request_with_v1_base_url, asserting that a client built with http://test-api/v1 hits http://test-api/health and http://test-api/proxy/openai/v1/models respectively. The previous tests passed only because they built a client without /v1.

    Verification

    • task test: 43 passed, 1 xfailed (pre-existing, unrelated to this fix), including both new regression tests.
    • task lint: black, isort, and mypy all clean.

    Housekeeping

    Model: ollama_cloud/glm-5.3-flash · Exit Code: 0 · Duration: 3m 15s

    Tokens: 1,070,481 in · 12,916 out · 1,083,397 total (27 requests)

    Tool calls: 45 total · 100% success rate

    Traces
    Session: 1790376590-5d5d9d12
    
    session (headless, success)                                                                         3m6s
    ├── chat ollama_cloud/glm-5.3-flash                                                                12.0s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                      12.0s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    12.0s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            12.0s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                12.0s
    ├── execute_tool TodoWrite call_hv98punb                                                            72µs
    ├── execute_tool Bash call_qs3due31                                                                295ms
    ├── execute_tool Bash call_cs17gkid                                                                  5ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 1.6s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.6s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.6s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.6s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.6s
    ├── execute_tool Bash call_prbruagg                                                                 1.5s
    ├── execute_tool Bash call_a0qs6faq                                                                  4ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 2.1s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.0s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.0s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.0s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.0s
    ├── execute_tool Bash call_uh79qc7q                                                                637ms
    ├── execute_tool Bash call_tt9dn2s1                                                                 1.4s
    ├── chat ollama_cloud/glm-5.3-flash                                                                 1.3s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.3s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.3s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.3s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.3s
    ├── execute_tool Read call_zok6kgxh                                                                245µs
    ├── execute_tool Read call_lof7xzd4                                                                167µs
    ├── chat ollama_cloud/glm-5.3-flash                                                                 2.2s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.2s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.2s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.2s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.2s
    ├── execute_tool Grep call_5oo6o2jj                                                                850µs
    ├── execute_tool Grep call_xasceuo0                                                                  1ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 2.2s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.2s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.2s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.2s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.2s
    ├── execute_tool Grep call_iowjqnum                                                                339µs
    ├── execute_tool Read call_jfl8mn7p                                                                283µs
    ├── execute_tool Read call_nybqxj20                                                                296µs
    ├── chat ollama_cloud/glm-5.3-flash                                                                16.3s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                      16.3s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    16.3s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            16.3s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                16.3s
    ├── execute_tool Grep call_qae82lsc                                                                  5ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 5.2s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.2s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.2s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.2s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.2s
    ├── execute_tool MultiEdit call_8w4j4vqe                                                             1ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 7.2s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       7.2s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     7.2s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             7.2s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 7.2s
    ├── execute_tool MultiEdit call_7x82731b                                                           734µs
    ├── chat ollama_cloud/glm-5.3-flash                                                                 5.6s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.6s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.6s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.6s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.6s
    ├── execute_tool TodoWrite call_ozlvgvgs                                                            72µs
    ├── execute_tool Bash call_58mpt6w1                                                                 41ms [error: tool_error]
    ├── chat ollama_cloud/glm-5.3-flash                                                                 5.5s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.5s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.5s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.5s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.5s
    ├── execute_tool Bash call_t36xn72o                                                                 12ms
    ├── execute_tool Bash call_90wqpr4w                                                                 27ms [error: tool_error]
    ├── execute_tool Bash call_o10r0j8e                                                                 12ms [error: tool_error]
    ├── chat ollama_cloud/glm-5.3-flash                                                                 7.3s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       7.3s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     7.3s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             7.3s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 7.3s
    ├── execute_tool Bash call_zg0bilt0                                                                11.1s
    ├── chat ollama_cloud/glm-5.3-flash                                                                 7.8s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       7.8s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     7.8s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             7.8s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 7.8s
    ├── execute_tool Memory call_ec0c9hgu                                                               1.2s
    ├── execute_tool Bash call_1yzkvrai                                                                902ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 3.7s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.7s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.7s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.7s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.7s
    ├── execute_tool Bash call_i8sec1cf                                                                821ms
    ├── execute_tool Bash call_gtzns8qs                                                                  4ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 3.9s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.9s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.9s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.9s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.9s
    ├── execute_tool Bash call_r2409mrl                                                                 2.8s
    ├── chat ollama_cloud/glm-5.3-flash                                                                11.4s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                      11.4s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    11.3s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            11.3s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                11.3s
    ├── execute_tool Bash call_7gqysx1e                                                                  4ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 3.6s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.6s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.6s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.6s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.6s
    ├── execute_tool Bash call_vvsb1xsf                                                                  4ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 2.9s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.9s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.9s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.9s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.9s
    ├── execute_tool Bash call_v0ckl5jh                                                                276ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 5.7s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.7s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.7s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.7s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.7s
    ├── execute_tool Bash call_gtx6ejhb                                                                 1.3s
    ├── execute_tool Write call_gtl1oq4v                                                               676µs
    ├── chat ollama_cloud/glm-5.3-flash                                                                 6.0s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       6.0s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     6.0s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             6.0s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 6.0s
    ├── execute_tool Bash call_r4ngusi6                                                                 1.6s
    ├── chat ollama_cloud/glm-5.3-flash                                                                 4.8s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.8s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.8s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.8s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.8s
    ├── execute_tool Bash call_kshhqy09                                                                671ms
    ├── execute_tool WebFetch call_fc2m7dff                                                             38ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                12.3s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                      12.3s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    12.3s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            12.3s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                12.3s
    ├── execute_tool TodoWrite call_gh6140hi                                                            63µs
    ├── execute_tool Write call_qo1b1coh                                                               624µs
    ├── chat ollama_cloud/glm-5.3-flash                                                                 1.2s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.2s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.2s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.2s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.2s
    ├── execute_tool Bash call_58qpz8qp                                                                 1.0s
    ├── chat ollama_cloud/glm-5.3-flash                                                                 2.6s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.6s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.6s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.6s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.6s
    ├── execute_tool TodoWrite call_zj8enycq                                                            48µs
    ├── execute_tool Bash call_8j9qrnrb                                                                 1.3s
    ├── chat ollama_cloud/glm-5.3-flash                                                                 5.3s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.3s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.3s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.3s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.3s
    ├── execute_tool Bash call_nvp701gj                                                                  3ms
    ├── execute_tool Bash call_tdgp6e5p                                                                  3ms
    ├── execute_tool Bash call_wpudjy8i                                                                466ms
    ├── chat ollama_cloud/glm-5.3-flash                                                                 5.1s
    │   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.1s
    │       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.1s
    │           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.1s
    │               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.1s
    ├── execute_tool TodoWrite call_3bt2m6vy                                                            60µs
    ╰── chat ollama_cloud/glm-5.3-flash                                                                 8.6s
        ╰── POST /v1/chat/completions [inference-gateway, server]                                       8.5s
            ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     8.5s
                ╰── POST /proxy/:provider/*path [inference-gateway, server]                             8.5s
                    ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 8.5s
    
    Stats
    Tool Calls
    
    ╭───────────┬───────┬───────┬────────╮
    │ Tool      │ Calls │ Fail% │ Avg    │
    ├───────────┼───────┼───────┼────────┤
    │ Bash      │ 26    │ 12%   │ 1012ms │
    │ TodoWrite │ 5     │ 0%    │ 59µs   │
    │ Grep      │ 4     │ 0%    │ 2ms    │
    │ Read      │ 4     │ 0%    │ 219µs  │
    │ MultiEdit │ 2     │ 0%    │ 859µs  │
    │ Write     │ 2     │ 0%    │ 641µs  │
    │ Memory    │ 1     │ 0%    │ 1207ms │
    │ WebFetch  │ 1     │ 0%    │ 39ms   │
    ╰───────────┴───────┴───────┴────────╯
    
    Token Usage
    
    ╭────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
    │ Model                      │ Prompt  │ Cached │ Completion │ Total   │ Cost │
    ├────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
    │ ollama_cloud/glm-5.3-flash │ 1070481 │ 797440 │ 12916      │ 1083397 │ -    │
    ╰────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯
    
    Sessions
    
    ╭───────────┬──────────┬──────────╮
    │ Execution │ Mode     │ Sessions │
    ├───────────┼──────────┼──────────┤
    │ headless  │ headless │ 1        │
    ╰───────────┴──────────┴──────────╯
    

    Triggered by edenreich · Infer Action · OSS

  3. moved this from QA to Done in 2026on Sep 25, 2026
  4. inference-gateway-releaser commented on Sep 26, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.21.1 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions