-1

Our company uses Gravitee. I have my ML written in Python. I need to make available via API. How can I do it? I think I can use FastAPI to expose my code as an API. Will it be possible to "marry" gravitee and my part? Would it be better to use something else instead of FastAPI?

Thanks for any advice

AnnaS
  • 7
  • 1

1 Answers1

0

If I understand correctly, yes, you can create an API with FastAPI like:

from fastapi import FastAPI
app = FastAPI()

@app.get("/")
async def root():
    # call you ML python code here
    return {"message": "It's a cat!"}

Secondly, deploy it somewhere to be able to call your API internally in your company. Which mean that you should call your API like:

$ curl 'http://mlapi.internal.mycompany.com/'
{"message": "It's a cat!"}

And then, register your new API into gravitee like explain here and for example configure the rate limiting to manage your bill related to the resource needed by your ML API ;)

Note that if you also have an Access Management available, you can manage authentication without implementing it.

Hope it's help.

passionne
  • 56
  • 3
  • That makes sense. Could you please elaborate on what you meant by _Note that if you also have an Access Management available, you can manage authentication without implementing it._ – AnnaS Dec 02 '22 at 01:38
  • I mean that if you need to authenticate a user before accessing your api, and if you already have Access Management installed. As for API management, you can configure authentication provider: https://docs.gravitee.io/am/current/am_quickstart_app_setup.html – passionne Dec 05 '22 at 11:20