Abstract Renewable energy has penetrated power grid enterprises on a large scale. Due to the intermittency and volatility of renewable energy generation, it is necessary to build new flexible grid-side resources to ensure the safe and stable operation of the power grid, which will cause great pressure on cost allocation for power grid enterprises. This article considers four types of flexible grid-side resources and constructs a dual-level configuration optimization model for flexible grid-side resources under the penetration of renewable energy. Based on the configuration results, the cost scale of flexible grid-side resources is estimated and an improved ancillary service cost allocation model based on the Shapley value method is proposed to smooth the allocation of ancillary service costs in the cost of flexible grid-side resources between the two main bodies of renewable energy and load. The calculation results show that, when the penetration rate of renewable-energy power is 30% and 35%, respectively, the cost of flexible grid-side resources is 9.606 billion yuan and 21.518 billion yuan, respectively. The proportion of ancillary service costs allocated to load is relatively high—about five times that of the ancillary service costs allocated to renewable energy—and the higher the penetration rate of renewable energy, the higher the proportion of ancillary service costs allocated to renewable energy.