Are there any options to host a local ai and communicate with an api?

I want to chat with my custom knowledge base.