litellm - 💡(How to fix) Fix [Bug]: Pass-through multipart audio transcription endpoint returns UnicodeDecodeError [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24627Fetched 2026-04-08 01:37:33
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1subscribed ×1

Error Message

4\x10\xc4\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO\r\nContent-Disposition: form-data; name="model"\r\n\r\nscaleway-whisper-large-v3\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO\r\nContent-Disposition: form-data; name="language"\r\n\r\nen\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO--\r\n'}] ... File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 298, in jsonable_encoder encoded_value = jsonable_encoder( value, ...<4 lines>... sqlalchemy_safe=sqlalchemy_safe, ) File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 327, in jsonable_encoder return ENCODERS_BY_TYPEtype(obj) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 61, in <lambda> bytes: lambda o: o.decode(), ~~~~~~~~^^ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 212: invalid start byte

Fix Action

Fix / Workaround

main-v1.82.3-stable.patch.2

Code Example

pass_through_endpoints:
    - path: "/scaleway/v1/audio/transcriptions"
      target: "https://api.scaleway.ai/v1/audio/transcriptions"
      methods: ["POST"]
      headers:
        Authorization: "Bearer os.environ/SCW_SECRET_KEY"
      forward_headers: true

---

curl -i "http://localhost:<litellm_proxy_port>/scaleway/v1/audio/transcriptions" \
  -H "Authorization: Bearer <LITELLM_KEY>" \
  -F "[email protected]" \
  -F "model=scaleway-whisper-large-v3" \
  -F "language=en"

---

HTTP/1.1 100 Continue

HTTP/1.1 500 Internal Server Error
date: Thu, 26 Mar 2026 12:19:28 GMT
server: uvicorn
content-length: 21
content-type: text/plain; charset=utf-8

Internal Server Error

---

4\x10\xc4\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO\r\nContent-Disposition: form-data; name="model"\r\n\r\nscaleway-whisper-large-v3\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO\r\nContent-Disposition: form-data; name="language"\r\n\r\nen\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO--\r\n'}]
...
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 298, in jsonable_encoder
    encoded_value = jsonable_encoder(
        value,
    ...<4 lines>...
        sqlalchemy_safe=sqlalchemy_safe,
    )
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 327, in jsonable_encoder
    return ENCODERS_BY_TYPE[type(obj)](obj)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 61, in <lambda>
    bytes: lambda o: o.decode(),
                     ~~~~~~~~^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 212: invalid start byte

---

pass_through_endpoints:
    - path: "/scaleway/v1/audio/transcriptions"
      target: "https://api.scaleway.ai/v1/audio/transcriptions"
      methods: ["POST"]
      headers:
        Authorization: "Bearer os.environ/SCW_SECRET_KEY"
      forward_headers: true

---

curl -i "http://localhost:<litellm_proxy_port>/scaleway/v1/audio/transcriptions" \
  -H "Authorization: Bearer <LITELLM_KEY>" \
  -F "[email protected]" \
  -F "model=scaleway-whisper-large-v3" \
  -F "language=en"

---

x1a\x89\x92PU\xd9)b%\xa8b$J\xe4\x84C\xff\xf38\xc4U\x0f\xb8r@\x12\x1b\x0c\x00\x9f:{\xf1\x15\xbd\xbdC\xf2S\xca=\\\x94\xf2\xb3\xda\xdd<\xf4\x95\x92\xebt\xf0\x96KS\xfd\xa9\xf9g*LAME3.100\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xff\xf38\xc4u\r\x88\x1e 4\x10\xc4\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\r\n--------------------------Xm5hv9BUeUCWFgIU19xVHN\r\nContent-Disposition: form-data; name="model"\r\n\r\nscaleway-whisper-large-v3\r\n--------------------------Xm5hv9BUeUCWFgIU19xVHN\r\nContent-Disposition: form-data; name="language"\r\n\r\nen\r\n--------------------------Xm5hv9BUeUCWFgIU19xVHN--\r\n'}]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py", line 406, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.scope, self.receive, self.send
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/applications.py", line 1134, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/lib/python3.13/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/lib/python3.13/site-packages/litellm/proxy/middleware/in_flight_requests_middleware.py", line 46, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/litellm/proxy/middleware/prometheus_auth_middleware.py", line 37, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/lib/python3.13/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/routing.py", line 716, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/routing.py", line 736, in app
    await route.handle(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/routing.py", line 290, in handle
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/fastapi/routing.py", line 124, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/_exception_handler.py", line 59, in wrapped_app
    response = await handler(conn, exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/exception_handlers.py", line 25, in request_validation_exception_handler
    content={"detail": jsonable_encoder(exc.errors())},
                       ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 312, in jsonable_encoder
    jsonable_encoder(
    ~~~~~~~~~~~~~~~~^
        item,
        ^^^^^
    ...<7 lines>...
        sqlalchemy_safe=sqlalchemy_safe,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 298, in jsonable_encoder
    encoded_value = jsonable_encoder(
        value,
    ...<4 lines>...
        sqlalchemy_safe=sqlalchemy_safe,
    )
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 327, in jsonable_encoder
    return ENCODERS_BY_TYPE[type(obj)](obj)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 61, in <lambda>
    bytes: lambda o: o.decode(),
                     ~~~~~~~~^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 212: invalid start byte
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Since audio support is not yet implemented for the Scaleway provider in LiteLLM, we attempted to work around this by configuring a pass-through endpoint to Scaleway’s transcription API. The pass-through endpoint was created successfully, but requests to it return 500 Internal Server Error with a UnicodeDecodeError. The same multipart request works correctly when sent directly to Scaleway, which suggests the issue is in LiteLLM’s pass-through handling rather than the upstream provider

Config of the pass-through endpoint:

  pass_through_endpoints:
    - path: "/scaleway/v1/audio/transcriptions"
      target: "https://api.scaleway.ai/v1/audio/transcriptions"
      methods: ["POST"]
      headers:
        Authorization: "Bearer os.environ/SCW_SECRET_KEY"
      forward_headers: true

Query:

 curl -i "http://localhost:<litellm_proxy_port>/scaleway/v1/audio/transcriptions" \
  -H "Authorization: Bearer <LITELLM_KEY>" \
  -F "[email protected]" \
  -F "model=scaleway-whisper-large-v3" \
  -F "language=en"

Response:

HTTP/1.1 100 Continue

HTTP/1.1 500 Internal Server Error
date: Thu, 26 Mar 2026 12:19:28 GMT
server: uvicorn
content-length: 21
content-type: text/plain; charset=utf-8

Internal Server Error

Logs from the proxy gateway:

4\x10\xc4\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO\r\nContent-Disposition: form-data; name="model"\r\n\r\nscaleway-whisper-large-v3\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO\r\nContent-Disposition: form-data; name="language"\r\n\r\nen\r\n--------------------------2gM0HjQVrGhvOjSnWToSTO--\r\n'}]
...
 File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 298, in jsonable_encoder
   encoded_value = jsonable_encoder(
       value,
   ...<4 lines>...
       sqlalchemy_safe=sqlalchemy_safe,
   )
 File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 327, in jsonable_encoder
   return ENCODERS_BY_TYPE[type(obj)](obj)
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
 File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 61, in <lambda>
   bytes: lambda o: o.decode(),
                    ~~~~~~~~^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 212: invalid start byte

Steps to Reproduce

  1. Make a pass-through endpoint pointing to https://api.scaleway.ai/v1/audio/transcriptions. This requires a scaleway API key
  pass_through_endpoints:
    - path: "/scaleway/v1/audio/transcriptions"
      target: "https://api.scaleway.ai/v1/audio/transcriptions"
      methods: ["POST"]
      headers:
        Authorization: "Bearer os.environ/SCW_SECRET_KEY"
      forward_headers: true
  1. Try and make a normal /v1/audio/transcriptions request:
 curl -i "http://localhost:<litellm_proxy_port>/scaleway/v1/audio/transcriptions" \
  -H "Authorization: Bearer <LITELLM_KEY>" \
  -F "[email protected]" \
  -F "model=scaleway-whisper-large-v3" \
  -F "language=en"
  1. See the errors occur like described above.

Relevant log output

x1a\x89\x92PU\xd9)b%\xa8b$J\xe4\x84C\xff\xf38\xc4U\x0f\xb8r@\x12\x1b\x0c\x00\x9f:{\xf1\x15\xbd\xbdC\xf2S\xca=\\\x94\xf2\xb3\xda\xdd<\xf4\x95\x92\xebt\xf0\x96KS\xfd\xa9\xf9g*LAME3.100\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xff\xf38\xc4u\r\x88\x1e 4\x10\xc4\x00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\r\n--------------------------Xm5hv9BUeUCWFgIU19xVHN\r\nContent-Disposition: form-data; name="model"\r\n\r\nscaleway-whisper-large-v3\r\n--------------------------Xm5hv9BUeUCWFgIU19xVHN\r\nContent-Disposition: form-data; name="language"\r\n\r\nen\r\n--------------------------Xm5hv9BUeUCWFgIU19xVHN--\r\n'}]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py", line 406, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.scope, self.receive, self.send
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/applications.py", line 1134, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/lib/python3.13/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/lib/python3.13/site-packages/litellm/proxy/middleware/in_flight_requests_middleware.py", line 46, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/litellm/proxy/middleware/prometheus_auth_middleware.py", line 37, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/lib/python3.13/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/routing.py", line 716, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/routing.py", line 736, in app
    await route.handle(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/routing.py", line 290, in handle
    await self.app(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/fastapi/routing.py", line 124, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/lib/python3.13/site-packages/starlette/_exception_handler.py", line 59, in wrapped_app
    response = await handler(conn, exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/exception_handlers.py", line 25, in request_validation_exception_handler
    content={"detail": jsonable_encoder(exc.errors())},
                       ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 312, in jsonable_encoder
    jsonable_encoder(
    ~~~~~~~~~~~~~~~~^
        item,
        ^^^^^
    ...<7 lines>...
        sqlalchemy_safe=sqlalchemy_safe,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 298, in jsonable_encoder
    encoded_value = jsonable_encoder(
        value,
    ...<4 lines>...
        sqlalchemy_safe=sqlalchemy_safe,
    )
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 327, in jsonable_encoder
    return ENCODERS_BY_TYPE[type(obj)](obj)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/lib/python3.13/site-packages/fastapi/encoders.py", line 61, in <lambda>
    bytes: lambda o: o.decode(),
                     ~~~~~~~~^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 212: invalid start byte

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

main-v1.82.3-stable.patch.2

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

The issue arises from the fact that the fastapi framework is trying to decode the request body as JSON, which fails because the body contains binary audio data. To fix this, we need to configure the pass-through endpoint to handle multipart/form-data requests correctly.

Here are the steps to fix the issue:

  • Update the pass_through_endpoints configuration to include the content_type parameter:
pass_through_endpoints:
  - path: "/scaleway/v1/audio/transcriptions"
    target: "https://api.scaleway.ai/v1/audio/transcriptions"
    methods: ["POST"]
    headers:
      Authorization: "Bearer ${SCW_SECRET_KEY}"
    forward_headers: true
    content_type: "multipart/form-data"
  • In the litellm/proxy/middleware/in_flight_requests_middleware.py file, update the __call__ method to handle multipart/form-data requests:
from fastapi import Request
from starlette.datastructures import FormData

async def __call__(self, scope, receive, send):
    # ...
    if scope["method"] == "POST" and scope["headers"].get("Content-Type") == "multipart/form-data":
        form_data = await FormData.parse_async(scope, receive)
        # Forward the form data to the target endpoint
        async with httpx.AsyncClient() as client:
            response = await client.post(
                self.target,
                headers=self.headers,
                data=form_data,
                files=form_data.files,
            )
            # ...
    # ...
  • Make sure to install the httpx library if it's not already installed:
pip install httpx

Verification

To verify that the fix worked, send a request to the pass-through endpoint using the curl command:

curl -i "http://localhost:<litellm_proxy_port>/scaleway/v1/audio/transcriptions" \
  -H "Authorization: Bearer <LITELLM_KEY>" \
  -F "[email protected]" \
  -F "model=scaleway-whisper-large-v3" \
  -F "language=en"

If the fix is successful, the request should be forwarded to the Scaleway API correctly, and you should receive a response without any errors.

Extra Tips

  • Make sure to update the SCW_SECRET_KEY environment variable with the correct value.
  • If you're using a different version of the fastapi framework, you may need to adjust the code accordingly.
  • Consider adding error handling and logging to the in_flight_requests_middleware to handle any potential issues that may arise during the request forwarding process.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING