Provisioning services for Internet of Things (IoT) devices leads to several challenges: heterogeneity of IoT devices, varying Quality of Services requirements, and increasing availability of both Cloud and Fog resources. The last of these is most significant to cope with Cloud infrastructure providers (CIPs) limitations for latency-sensitive services. Many Fog infrastructure providers (FIPs) have recently emerged, and their number is increasing continually. Selecting a suitable provider for each service involves considering multiple factors such as the provider’s available resources, geographic location, quality of service, and cost. Motivated by this, FLEX is proposed in this work as a platform for service placement in a multi-Fog and multi-Cloud environment. For each service, FLEX broadcasts service requirements to the resource managers (RMs) of the available Fog and Cloud service providers and then selects the most suitable provider for that service. FLEX is scalable and flexible as it leaves it up to the RMs to have their own policy for the placement of submitted services. Also, the problem of service placement in multi-provider environments has been formulated as an optimization problem to jointly minimize the total weighted delay and cost of services. Next, a heuristic algorithm, namely minimum cost and delay first (MCD1), is proposed to map services to FIPs and CIPs efficiently.To evaluate the performance of the proposed algorithm, extensive experiments are conducted to analyze the behavior of the algorithm under different scenarios, such as a varying number of services, providers, and the ratio of FIPs. Results show that MCD1 significantly performs better than baseline methods and genetic algorithms. In particular, the proposed algorithm can reduce the objective function value up to 26.8%.