added opt_generator, and special condition to api_call