Render a frame in unreal via c++ code

Hi folks,
I am trying to take a 2d render of a viewport that is loaded in the Unreal editor via the C++ code.
This is what the setup looks like -
There is an interactive render button which when clicked would trigger a 2d render of the viewport.
The challenge that we are facing right now is we are unable to add a levelSequenceCapture to the build.
I tried using the AutomatedLevelSequenceCapture class object but when I initialize it to trigger a render I get the error -
“]LogMovieSceneCapture: Error: Could not find or create a Level Sequence Actor for this capture. Capturing will fail.”
I am not sure how to go about this.
Any help would be appreciated.
Adding the code block for reference

TSharedPtr scene_viewport = MakeShareable(new FSceneViewport(GEngine->GameViewport, GEngine->GameViewport->GetGameViewportWidget()));
automatedLevelSequenceCapture->Initialize(scene_viewport);