Since you're using the API, any particular reason why you didn't just use Librechat? It already has support for API keys for Claude, OpenAI, and you can also use it with locally hosted LLMs through Ollama, and has all of the same feature (saved conversations, file attachments, caching, etc.)
https://github.com/danny-avila/LibreChat