Endoprosthetic hip replacement is the conventional way to treat osteoarthritis or a fracture of a dysfunctional joint. Different manufacturing methods are employed to create reliable patient‐specific devices with long‐term performance and biocompatibility. Recently, additive manufacturing has become a promising technique for the fabrication of medical devices, because it allows to produce complex samples with various structures of pores. Moreover, the limitations of traditional fabrication methods can be avoided. It is known that a well‐designed porous structure provides a better proliferation of cells, leading to improved bone remodeling. Additionally, porosity can be used to adjust the mechanical properties of designed structures. This makes the design and choice of the structure's basic cell a crucial task. This study focuses on a novel computational method, based on the basic‐cell concept to design a hip endoprosthesis with an unregularly complex structure. A cube with spheroid pores was utilized as a basic cell, with each cell having its own porosity and mechanical properties. A novelty of the suggested method is in its combination of the topology optimization method and the structural design algorithm. Bending and compression cases were analyzed for a cylinder structure and two hip implants. The ability of basic‐cell geometry to influence the structure's stress–strain state was shown. The relative change in the volume of the original structure and the designed cylinder structure was 6.8%. Computational assessments of a stress–strain state using the proposed method and direct modeling were carried out. The volumes of the two types of implants decreased by 9% and 11%, respectively. The maximum von Mises stress was 600 MPa in the initial design. After the algorithm application, it increased to 630 MPa for the first type of implant, while it is not changing in the second type of implant. At the same time, the load‐bearing capacity of the hip endoprostheses was retained. The internal structure of the optimized implants was significantly different from the traditional designs, but better structural integrity is likely to be achieved with less material. Additionally, this method leads to time reduction both for the initial design and its variations. Moreover, it enables to produce medical implants with specific functional structures with an additive manufacturing method avoiding the constraints of traditional technologies.