How do you call `bpy.ops.clip.rebuild_proxy()` in the python api without getting a context is incorrect error I am trying to get proxy timecodes rendered for the blender nle via the python API. However once I call bpy.ops.clip.rebuild_proxy() or bpy.ops.sequencer.rebuild_proxy() instantly get the error RuntimeError: Operator bpy.ops.clip.rebuild_proxy.poll() failed, context is incorrect
I have tried tracking down the function in C but I cannot find anything that helps point towards the root cause, or how to properly call rebuild_proxy()
So it sounds like the problem is that the wrong part of the interface ('Area') is active at the moment you're calling ops.clip.rebuild_proxy() or sequencer.rebuild_proxy().

I'm working on an add-on that will allow me to add a movie strip, draw waveforms, and start a 50% proxy build all with a single action. I found that I had to iterate through the areas and override the context to rebuild proxy for a specific clip. Here's what worked for me: 

ctx = bpy.context.copy()
for area in bpy.context.screen.areas:
    if area.type == 'CLIP_EDITOR':
        ctx['area'] = area
        bpy.ops.clip.rebuild_proxy()