You will have to switch context. Because not all operators are available within every context, due to the
poll method, that is supposed to makes things a little bit more safe and organized. But anyway you can bypass this restriction.
This is an except from one of my scripts but it shows the technique used. If I remember correctly this code works, only if Image Editor panel is available in front of the user. So it means that the code will work best only with a template .blend file loaded (with proper UI setup) and the script then run from command line.
# access image editor context to save it
# (ALTERNATIVE - BUT CONTEXT CONSTRAINED)
done = False
for area in context.screen.areas:
if area.type == 'IMAGE_EDITOR':
ctx = bpy.context.copy()
ctx['area'] = area
ctx['region'] = [x for x in area.regions if x.type == 'WINDOW']
bpy.ops.image.save_as(ctx, save_as_render=True, copy=True, filepath="//untitled.png", relative_path=True, show_multiview=False, use_multiview=False)
done = True