How to render an image through the text editor?
Possible duplicate of: Rendering a cube as png file using Blender's Python API.
(I would put this in a comment if I had enough reputation.)

The above answer includes the following, with the assumption your camera is already set up (note that I have not tested the code):


  Set the render settings of the current scene, and render it. write_still is necessary if you want the result to be written to the filepath. There will be no visual feedback during the render process.


# render settings
scene = bpy.context.scene
scene.render.image_settings.file_format = 'PNG'
scene.render.filepath = "F:/image.png"
bpy.ops.render.render(write_still = 1)