AttributeError: 'ray._raylet.ObjectRef' object has no attribute 'save'

I’m running inference on a stable diffusion model on aws inf2 instance using rayserve. I’m running into the below issue when I try to do
Any idea on how can I fix this issue?

File "/home/ray/anaconda3/lib/python3.10/site-packages/fastapi/middleware/", line 17, in __call__
412    await, receive, send)
413  File "/home/ray/anaconda3/lib/python3.10/site-packages/starlette/", line 754, in __call__
414    await self.middleware_stack(scope, receive, send)
415  File "/home/ray/anaconda3/lib/python3.10/site-packages/starlette/", line 774, in app
416    await route.handle(scope, receive, send)
417  File "/home/ray/anaconda3/lib/python3.10/site-packages/starlette/", line 296, in handle
418    await, receive, send)
419  File "/home/ray/anaconda3/lib/python3.10/site-packages/starlette/", line 75, in app
420    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
421  File "/home/ray/anaconda3/lib/python3.10/site-packages/starlette/", line 64, in wrapped_app
422    raise exc
423  File "/home/ray/anaconda3/lib/python3.10/site-packages/starlette/", line 53, in wrapped_app
424    await app(scope, receive, sender)
425  File "/home/ray/anaconda3/lib/python3.10/site-packages/starlette/", line 70, in app
426    response = await func(request)
427  File "/home/ray/anaconda3/lib/python3.10/site-packages/fastapi/", line 241, in app
428    raw_response = await run_endpoint_function(
429  File "/home/ray/anaconda3/lib/python3.10/site-packages/fastapi/", line 167, in run_endpoint_function
430    return await**values)
431  File "/serve_app/", line 34, in generate
432, "PNG")
433AttributeError: 'ray._raylet.ObjectRef' object has no attribute 'save'

image must be awaited before it can be used. It’s still a Ray ObjectRef. Can you try adding the following line before saving the image:

image = await image