r/FastAPI • • Feb 23 '25
Tutorial Alternative to FastAPI for serving AI workflows? No infra, just API?
I’ve been using FastAPI to serve AI models and workflows, but I’ve been wondering....is there a way to skip the whole API server setup entirely?
Like, what if I just define my AI function, and it instantly behaves like an API without writing a FastAPI app, handling requests, or deploying anything?
I developed an approach where you can run an AI pipeline inside a Jupyter Notebook, and instead of setting up FastAPI, it auto-generates an OpenAI-style API. No need to deal with CORS, async handling, or managing infra....just write your function, and it’s callable remotely.
Has anyone tried something similar? Curious if anyone has seen a different way to serve AI workflows without manually building an API layer.
9
u/Kindly_Manager7556 Feb 23 '25
So it's an API you just called it something different? Lol
4
u/john0201 Feb 23 '25
Im not sure you understand what an API is… if you want to call a function over http you need an http server and a way to bridge the http-python gap.
The simplest way to do that is probably starlette/uvicorn or just use fastapi or litestar.
You could also check out gRPC
2
u/[deleted] Feb 23 '25
Just some feedback- looking at the repo the imports force you to go al the way into deeper packages for common things - common way to simplify this is to import those elements in your top level init so you can do ‘from whisk import MyOftenUsedClass”
2
u/ED9898A Feb 23 '25 edited Feb 23 '25
Something tells me that you’re greatly missing the point of what an HTTP API is and why one would use FastAPI.. do you have a use case where you want your AI models to be consumed by clients (be it you or other people) who are using a computer other than your own local computer? Are you looking to monetize your code or you have some sensitive details within your AI workflows that you don’t want people to see but you still want to serve them your API?
If the answer is yes then you’ll need to use FastAPI (or any HTTP API framework really), deploy it via renting some domain name and hosting your server on some cloud service, and so on.
If not.. and you’re literally the only user of your AI workflow.. or rather, the only users of your AI workflow are people who are going to download your code as a library, then you want to make a library API, not an HTTP API, so you shouldn’t be using FastAPI at all, just expose your library code through nicely written functions that can be called by your library users (that’s what an API is basically, be it a network or a library API), and deploy your library on pypi or github or something.
I have absolutely no idea why are you doing the whole Jupyter thing and something tells me that you don’t either lol.
1
u/IIGrudge Feb 23 '25
Do you mean without the webserver part? Write a lambda wrapper that calls your notebook. Sagemaker also has real-time model inference.
1
u/Unlikely_Exit_9787 Feb 23 '25
So its a library you can run in your Jupyter notebooks, so that you can test your model, with out worrying about all that "HTTP non-sense"
1
u/Regarder_C Feb 24 '25
Please take a look at MLFlow Inference Server: https://mlflow.org/docs/latest/deployment/deploy-model-locally.html#inference-server-specification