Title: OpenAIIntegration breaks litellm streaming — LegacyAPIResponse wraps Stream objects · Issue #5890 · getsentry/sentry-python · GitHub
Open Graph Title: OpenAIIntegration breaks litellm streaming — LegacyAPIResponse wraps Stream objects · Issue #5890 · getsentry/sentry-python
X Title: OpenAIIntegration breaks litellm streaming — LegacyAPIResponse wraps Stream objects · Issue #5890 · getsentry/sentry-python
Description: How do you use Sentry? Sentry SaaS (sentry.io) Version sentry-sdk 2.56.0 Steps to Reproduce import sentry_sdk import litellm sentry_sdk.init(dsn="...") # OpenAIIntegration auto-enables # This fails: response = litellm.completion( model="...
Open Graph Description: How do you use Sentry? Sentry SaaS (sentry.io) Version sentry-sdk 2.56.0 Steps to Reproduce import sentry_sdk import litellm sentry_sdk.init(dsn="...") # OpenAIIntegration auto-enables # This fails...
X Description: How do you use Sentry? Sentry SaaS (sentry.io) Version sentry-sdk 2.56.0 Steps to Reproduce import sentry_sdk import litellm sentry_sdk.init(dsn="...") # OpenAIIntegration auto-enables # ...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/5890
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OpenAIIntegration breaks litellm streaming — LegacyAPIResponse wraps Stream objects","articleBody":"## How do you use Sentry?\nSentry SaaS (sentry.io)\n\n## Version\nsentry-sdk 2.56.0\n\n## Steps to Reproduce\n\n```python\nimport sentry_sdk\nimport litellm\n\nsentry_sdk.init(dsn=\"...\") # OpenAIIntegration auto-enables\n\n# This fails:\nresponse = litellm.completion(\n model=\"gpt-4.1-nano\",\n messages=[{\"role\": \"user\", \"content\": \"hello\"}],\n stream=True,\n)\nfor chunk in response:\n print(chunk)\n```\n\n**Versions:**\n- sentry-sdk==2.56.0\n- openai==2.30.0\n- litellm==1.82.6\n\n## Expected Result\n\nStreaming works normally. `litellm` iterates chunks from the OpenAI response.\n\n## Actual Result\n\n```\nlitellm.InternalServerError: OpenAIException - 'LegacyAPIResponse' object has no attribute '_iterator'\nLiteLLM Retried: 3 times\n```\n\nThe `OpenAIIntegration` monkey-patches the openai client and wraps the streaming response in a `LegacyAPIResponse` object. This object lacks the `_iterator` attribute that litellm expects on `Stream` objects. The OpenAI API returns `200 OK` every time — the error occurs when litellm tries to iterate the wrapped response.\n\n**Workaround:**\n\n```python\nfrom sentry_sdk.integrations.openai import OpenAIIntegration\n\nsentry_sdk.init(\n dsn=\"...\",\n disabled_integrations=[OpenAIIntegration],\n)\n```\n\nDisabling only `OpenAIIntegration` fixes the issue. All other auto-enabled integrations (HttpxIntegration, LiteLLMIntegration, etc.) work fine.","author":{"url":"https://github.com/iRbouh","@type":"Person","name":"iRbouh"},"datePublished":"2026-03-26T19:50:42Z","url":"https://github.com/getsentry/sentry-python/issues/5890"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f9a88a44-d258-6e2e-6bbf-7735b1feb7a6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C446:2679E9:188773:21ABE2:6B00BE25 |
| html-safe-nonce | ab3341131dcf194b3335bf74ec7f2b8c0ebfa0d90be817a7817aa5039414744e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDQ2OjI2NzlFOToxODg3NzM6MjFBQkUyOjZCMDBCRTI1IiwidmlzaXRvcl9pZCI6IjkyMDQxMDg3NTgxNDAxMDgzMjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ed2d7009fb5ad367f5457b25a94a8bdeffd2e41059f77d57de56441c04a925ad |
| hovercard-subject-tag | issue:4146924156 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/5890/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6bc05cc53b2dfc6608d3d323b7c81632671ba181cb796e51c937a5555a6d057/getsentry/sentry-python/issues/5890 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6bc05cc53b2dfc6608d3d323b7c81632671ba181cb796e51c937a5555a6d057/getsentry/sentry-python/issues/5890 |
| og:image:alt | How do you use Sentry? Sentry SaaS (sentry.io) Version sentry-sdk 2.56.0 Steps to Reproduce import sentry_sdk import litellm sentry_sdk.init(dsn="...") # OpenAIIntegration auto-enables # This fails... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iRbouh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fee81a280ea86312b69448e261b418189bfd5b5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width