We determine the k-essence Lagrangian of a relativistic barotropic fluid. The equation of state of the fluid can be specified in different manners depending on whether the pressure is expressed in terms of the energy density (model I), the rest-mass density (model II), or the pseudo rest-mass density for a complex scalar field in the Thomas-Fermi approximation (model III). In the nonrelativistic limit, these three formulations coincide. In the relativistic regime, they lead to different models that we study exhaustively. We provide general results valid for an arbitrary equation of state and show how the different models are connected to each other. For illustration, we specifically consider polytropic and logotropic dark fluids that have been proposed as unified dark matter and dark energy models. We recover the Born-Infeld action of the Chaplygin gas in models I and III and obtain the explicit expression of the reduced action of the logotropic dark fluid in models II and III. We also derive the two-fluid representation of the Chaplygin and logotropic models. Our general formalism can be applied to many other situations such as Bose-Einstein condensates with a |φ|4 (or more general) self-interaction, dark matter superfluids, and mixed models.