Skip to content

fix(client): carry HTTP status and error body into InferenceGatewayAPIError - #139

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

edenreich merged 1 commit into
mainfrom
fix/issue-132

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Resolves #132

Summary

With the default requests backend, every HTTP error surfaced as
InferenceGatewayAPIError with status_code=0 and response_data={},
breaking the README "Error Handling" contract. The root cause: the error
handler tested response truthiness, and requests.Response.__bool__
returns self.ok, which is False for every 4xx/5xx response. The three
streaming methods had the same gap on both backends and additionally let
connection failures escape as raw requests/httpx exceptions instead of
InferenceGatewayError.

Changes

  • New InferenceGatewayClient._api_error() helper builds the API error
    from the response using response is not None (not truthiness), so the
    real HTTP status and parsed JSON error body are carried on both
    backends; non-JSON bodies fall back to {}.
  • _make_request uses the helper, preserving existing fallback behavior
    when no response object exists.
  • All three streaming methods (create_chat_completion_stream,
    create_response_stream, create_message_stream) now:
    • raise InferenceGatewayAPIError with status_code and
      response_data (httpx error bodies are read via response.read()
      inside the stream context before parsing);
    • wrap connection failures from self.session.post(...) /
      self.client.stream(...) as InferenceGatewayError, matching
      non-streaming behavior.
  • Tests: added regression tests that use real requests.Response
    objects (Mock is always truthy, which hid the bug) covering
    non-streaming and streaming on both backends, plus non-JSON error
    bodies and connection failures; the synthetic
    Exception("API Error") stream scenario now uses a realistic
    requests.exceptions.ConnectionError.

Tests run: task lint (black, isort, mypy) and task test - 47 passed,
1 xfailed (pre-existing, unrelated).

no docs ticket: the README already documents this behavior; this PR
makes the SDK honor it. No schemas/models changes.

@edenreich

Copy link
Copy Markdown
Contributor

@infer Can you resolve the merge conflict?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Todos

Pull Request

#139

✅ Infer Result: Success

All done - the working tree is clean, the branch is in sync, and GitHub reports PR #139 as MERGEABLE. Final todo update:

Merge conflict resolved - PR #139 now reports mergeable: MERGEABLE on GitHub.

What the conflict was

Main advanced with PR #138 (4a1e48f: close() now also closes the requests Session, streaming methods pass timeout to session.post, plus root-route fixes for proxy_request/health_check and README/examples updates), while this PR (#132 fix) heavily rewrote the same client.py and tests/test_client.py regions - PR #132 moved the streaming session.post calls inside try blocks, exactly where #138 inserted the timeout= line, so a plain content fix alone would still leave overlapping 3-way merge hunks.

How it was resolved

  1. Ported all of main's deltas into the branch content:

    • close(): added elif hasattr(self, "session"): self.session.close() for the requests backend.
    • All three streaming methods (create_chat_completion_stream, create_response_stream, create_message_stream): timeout=self._timeout added to the session.post(...) calls, combined with the PR's existing error-handling rewrite.
    • proxy_request/health_check: switched to self._root_url (routes at the gateway root, /v1 suffix stripped) with the docstring notes from main.
    • Tests: added test_close_closes_http_backends, test_health_check_with_v1_base_url, test_proxy_request_with_v1_base_url, and timeout=30.0 in the five streaming assert_called_once_with assertions.
    • README/examples updates (examples/images/README.md etc.) taken from main verbatim.
  2. Validated: task install + task lint (black, isort, mypy) + task test - 50 passed, 1 xfailed (the xfail is the pre-existing upstream-spec marker, unrelated).

  3. Rebuilt the branch on top of current main (rebase-equivalent, since git merge/git rebase aren't available in this runner): a content-only resolution commit still left GitHub reporting CONFLICTING because the overlapping hunks persist from the shared base. The branch is now a single commit 1840afa with the original message and author preserved, directly on 4a1e48f, pushed with --force-with-lease. The final tree is byte-identical to the validated one.

  4. Verified: gh pr view 139 shows mergeable: MERGEABLE, mergeStateStatus: BLOCKED (blocked only on required checks/reviews, not conflicts). Working tree clean, branch synced with origin.

One note: the PR description's "Tests run: 47 passed" is now 50 passed (main's three new tests are included); happy to update the body if wanted.

Model: ollama_cloud/glm-5.3-flash · Exit Code: 0 · Duration: 9m 11s

Tokens: 3,669,193 in · 46,249 out · 3,715,442 total (43 requests)

Tool calls: 74 total · 100% success rate

Traces
Session: 1790377511-155907aa

session (headless, success)                                                                         9m3s
├── chat ollama_cloud/glm-5.3-flash                                                                 2.3s
│   ╰── 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 TodoWrite call_pjxywnyz                                                            70µs
├── execute_tool Bash call_yoniu3as                                                                  3ms
├── execute_tool Bash call_e2ovad6r                                                                544ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.4s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.4s
├── execute_tool Bash call_w3f0qjn6                                                                  6ms
├── execute_tool Bash call_5rrt66sj                                                                  3ms
├── chat ollama_cloud/glm-5.3-flash                                                                20.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      20.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    20.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            20.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                20.9s
├── execute_tool Bash call_c2tx1sjm                                                                  3ms
├── execute_tool Bash call_l15rr2qc                                                                  6ms
├── chat ollama_cloud/glm-5.3-flash                                                                44.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      44.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    44.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            44.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                44.8s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.5s
├── execute_tool Bash call_aa8tq6op                                                                  4ms
├── execute_tool Bash call_rm1zrbv7                                                                  4ms
├── chat ollama_cloud/glm-5.3-flash                                                                12.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      12.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    12.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            12.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                12.6s
├── execute_tool TodoWrite call_4uz4ubo0                                                            62µs
├── execute_tool Bash call_n1bqlwvi                                                                  3ms
├── chat ollama_cloud/glm-5.3-flash                                                                12.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      12.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    12.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            12.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                12.7s
├── execute_tool Grep call_ofnbjans                                                                355µs
├── execute_tool Bash call_27q45ib7                                                                  3ms
├── chat ollama_cloud/glm-5.3-flash                                                                11.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      11.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    11.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            11.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                11.5s
├── execute_tool Grep call_07axyxuu                                                                  1ms
├── execute_tool Grep call_dnkx2k35                                                                426µs
├── execute_tool Bash call_zu1lbrr5                                                                  4ms
├── chat ollama_cloud/glm-5.3-flash                                                                14.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      14.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    14.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            14.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                14.5s
├── execute_tool Read call_1f1l6gr4                                                                149µs
├── execute_tool Read call_r26vi9xm                                                                157µs
├── execute_tool Read call_dlingmpz                                                                207µs
├── chat ollama_cloud/glm-5.3-flash                                                                15.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      15.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    15.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            15.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                15.9s
├── execute_tool Grep call_gpzfq1bs                                                                337µs
├── execute_tool Grep call_bm2petq9                                                                387µs
├── execute_tool Grep call_9z77ow6i                                                                  1ms
├── chat ollama_cloud/glm-5.3-flash                                                                13.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      13.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    13.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            13.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                13.5s
├── execute_tool Read call_fd0m7q1g                                                                121µs
├── execute_tool Read call_ghhem1u0                                                                114µs
├── execute_tool Read call_bx8r879r                                                                106µs
├── execute_tool Read call_2wnqi1dp                                                                103µs
├── execute_tool Read call_txqxv2in                                                                 96µs
├── execute_tool Read call_5pkj990s                                                                105µs
├── execute_tool Read call_4njjh6vl                                                                101µs
├── execute_tool Read call_jux5u7ik                                                                105µs
├── chat ollama_cloud/glm-5.3-flash                                                                17.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      17.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    17.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            17.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                17.6s
├── execute_tool Read call_pii78ybr                                                                115µs
├── execute_tool Read call_ettjha5u                                                                172µs
├── chat ollama_cloud/glm-5.3-flash                                                                14.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      14.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    14.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            14.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                14.1s
├── execute_tool MultiEdit call_8ngjs0s5                                                           430µs [error: tool_error]
├── chat ollama_cloud/glm-5.3-flash                                                                11.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      11.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    11.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            11.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                11.9s
├── execute_tool Bash call_p3ikejoe                                                                 32ms
├── chat ollama_cloud/glm-5.3-flash                                                                 3.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.0s
├── execute_tool Bash call_wteghvol                                                                 10ms
├── execute_tool Bash call_logruh57                                                                 10ms
├── 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_4v02n7k3                                                                 10ms
├── chat ollama_cloud/glm-5.3-flash                                                                 6.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       6.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     6.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             6.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 6.6s
├── execute_tool MultiEdit call_hythr3jh                                                             1ms
├── 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_2yja412t                                                                 10ms
├── chat ollama_cloud/glm-5.3-flash                                                                14.9s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      14.8s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    14.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            14.8s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                14.8s
├── execute_tool MultiEdit call_t4gx906t                                                             1ms
├── chat ollama_cloud/glm-5.3-flash                                                                 5.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       5.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     5.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.0s
├── execute_tool TodoWrite call_i430nwyq                                                            49µs
├── execute_tool Bash call_rj4bszc9                                                                  5ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.7s
├── execute_tool Bash call_rpyde7iy                                                                  4ms
├── execute_tool Bash call_jezj9vui                                                                  3ms
├── 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 Bash call_ow9en4xp                                                                 40ms [error: tool_error]
├── chat ollama_cloud/glm-5.3-flash                                                                 2.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.7s
├── execute_tool Bash call_22prvrgy                                                                11.4s
├── 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 Bash call_9dfnpmct                                                                 3.6s
├── chat ollama_cloud/glm-5.3-flash                                                                 3.5s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.5s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.4s
├── execute_tool Bash call_7npgl4w5                                                                 1.2s
├── chat ollama_cloud/glm-5.3-flash                                                                 4.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.7s
├── execute_tool TodoWrite call_e67y0b08                                                            44µs
├── execute_tool Bash call_ui844jvn                                                                  5ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.7s
├── execute_tool Bash call_kaakl1ak                                                                277ms
├── chat ollama_cloud/glm-5.3-flash                                                                 1.7s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.7s
├── execute_tool Bash call_4n12wh1e                                                                 2.2s
├── chat ollama_cloud/glm-5.3-flash                                                                 7.9s
│   ╰── 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 Bash call_w6ts24qa                                                                  3ms
├── execute_tool Bash call_101tawny                                                                427ms
├── chat ollama_cloud/glm-5.3-flash                                                                53.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      53.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    53.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            53.0s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                53.0s
├── 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_r7u7hvx3                                                                20.0s
├── 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_zrv5ve19                                                                512ms
├── chat ollama_cloud/glm-5.3-flash                                                                41.2s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      41.2s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    41.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            41.2s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                41.2s
├── execute_tool Bash call_jtyxopez                                                                930ms
├── execute_tool Bash call_o7cp98xw                                                                  3ms
├── chat ollama_cloud/glm-5.3-flash                                                                56.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                      56.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]    56.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                            56.6s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                56.6s
├── chat ollama_cloud/glm-5.3-flash                                                                 4.4s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.3s
├── execute_tool TodoWrite call_ntaecmt3                                                            43µs
├── execute_tool Bash call_gtiifcqd                                                                  3ms
├── chat ollama_cloud/glm-5.3-flash                                                                 3.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       3.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     3.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             3.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 3.3s
├── execute_tool Bash call_m5pmzmjc                                                                  3ms
├── execute_tool Bash call_3c4vzudl                                                                  2ms
├── 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.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             5.4s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 5.4s
├── execute_tool Write call_alkvmw0g                                                               610µs
├── chat ollama_cloud/glm-5.3-flash                                                                 2.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.0s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.9s
├── execute_tool Bash call_ol8mh46y                                                                  3ms
├── chat ollama_cloud/glm-5.3-flash                                                                 2.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.3s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.3s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.3s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.3s
├── execute_tool Bash call_k3wxo7ir                                                                  5ms
├── chat ollama_cloud/glm-5.3-flash                                                                 2.0s
│   ╰── 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_ua99b6jd                                                                273ms
├── chat ollama_cloud/glm-5.3-flash                                                                 2.3s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.3s
│       ╰── 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 Bash call_ujl4sca0                                                                 1.4s
├── chat ollama_cloud/glm-5.3-flash                                                                 2.1s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       2.1s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     2.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             2.1s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 2.1s
├── execute_tool Bash call_16mk52g4                                                                25.0s
├── chat ollama_cloud/glm-5.3-flash                                                                 1.8s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       1.7s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     1.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             1.7s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 1.7s
├── execute_tool Bash call_3skd2rib                                                                680ms
├── chat ollama_cloud/glm-5.3-flash                                                                 9.0s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       8.9s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     8.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             8.9s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 8.9s
├── execute_tool Bash call_7fkhueux                                                                  3ms
├── execute_tool Memory call_rjkxm496                                                               1.3s
├── chat ollama_cloud/glm-5.3-flash                                                                 4.6s
│   ╰── POST /v1/chat/completions [inference-gateway, server]                                       4.6s
│       ╰── POST 127.0.0.1:8080/proxy/ollama_cloud/chat/completions [inference-gateway, client]     4.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway, server]                             4.5s
│               ╰── POST ollama.com/v1/chat/completions [inference-gateway, client]                 4.5s
├── execute_tool TodoWrite call_umj8weho                                                            45µs
╰── 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
Stats
Tool Calls

╭───────────┬───────┬───────┬────────╮
│ Tool      │ Calls │ Fail% │ Avg    │
├───────────┼───────┼───────┼────────┤
│ Bash      │ 42    │ 2%    │ 1635ms │
│ Read      │ 13    │ 0%    │ 117µs  │
│ TodoWrite │ 6     │ 0%    │ 51µs   │
│ Grep      │ 6     │ 0%    │ 634µs  │
│ MultiEdit │ 3     │ 33%   │ 1ms    │
│ Write     │ 1     │ 0%    │ 614µs  │
│ Memory    │ 1     │ 0%    │ 1298ms │
╰───────────┴───────┴───────┴────────╯

Token Usage

╭────────────────────────────┬─────────┬─────────┬────────────┬─────────┬──────╮
│ Model                      │ Prompt  │ Cached  │ Completion │ Total   │ Cost │
├────────────────────────────┼─────────┼─────────┼────────────┼─────────┼──────┤
│ ollama_cloud/glm-5.3-flash │ 3908629 │ 3377920 │ 70825      │ 3979454 │ -    │
╰────────────────────────────┴─────────┴─────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ headless │ 1        │
╰───────────┴──────────┴──────────╯

Triggered by edenreich · Infer Action · OSS

…IError

requests.Response.__bool__ returns self.ok, so every 4xx/5xx response is falsy and _make_request always fell back to status_code=0/response_data={}.

Streaming methods now also populate status_code/response_data (reading the error body first on httpx) and wrap connection failures from session.post / client.stream as InferenceGatewayError on both backends.
@edenreich
edenreich merged commit d58a54f into main Sep 25, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-132 branch September 25, 2026 23:33
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] InferenceGatewayAPIError loses status_code and response_data (requests backend, streams)

1 participant