# Ray with FastAPI

**URL:** https://discuss.ray.io/t/ray-with-fastapi/13211
**Category:** Ray Core
**Created:** [December 20, 2023, 8:29am UTC](https://discuss.ray.io/t/ray-with-fastapi/13211 "2023-12-20T08:29:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Fhuad\_Balogun](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/fhuad_balogun/32/5517_2.png) [@Fhuad\_Balogun](https://discuss.ray.io/u/Fhuad_Balogun)
#### Post date: [December 20, 2023, 8:29am UTC](https://discuss.ray.io/t/ray-with-fastapi/13211/1 "2023-12-20T08:29:24Z")

</div>

Hello everyone

I am new to Ray.

I have followed the steps to configure a Ray cluster on AWS.

My challenge now is I have an api built using Fastapi. an endpoint from the api collects request from user to create inference by a machine learning model.

I want to use Ray for distributing workloads for this ML model on multiple nodes. This will increase speed of creating inference for large input data.

I want to be able to deploy the Fastapi app (along with the ML model service) somewhere, and when request come in for inference:

1. In the Fastapi app, I initialize Ray with ray.init and connect to the remote ray cluster.
2. Call the function that creates the inference using Ray’s .remote()
3. The Ray remote cluster runs the workload in distributed fashion using the head node and worker nodes created on AWS.
4. Fastapi awaits the futures using Ray’s .get(), once ready, Ray sends the result back and Fastapi respond to the user.

Is this possible with Ray and Fastapi?

---

<div class="post-metadata">

### Author: ![jjyao](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jjyao/32/1799_2.png) [@jjyao](https://discuss.ray.io/u/jjyao)
#### Post date: [December 24, 2023, 2:44am UTC](https://discuss.ray.io/t/ray-with-fastapi/13211/2 "2023-12-24T02:44:38Z")

</div>

Have you considered Ray Serve: [Ray Serve: Scalable and Programmable Serving — Ray 2.9.0](https://docs.ray.io/en/latest/serve/index.html) which has Fastapi integration.
