I do not think you can do it in that way. Instead I can suggest my project https://github.com/reagento/dishka/ which can be used in different ways (like without fastapi or directly requesting dependency)