I failed to find any official docs if OpenStreetMap provide any API for directions. Maybe there is some other free service for this task?
There is no more "free", although Google does (at present), give you some usage without charging.
The OpenStreetMap API is free.
The Directions API uses a pay-as-you-go pricing model. Directions API requests generate calls to one of two SKUs depending on the type of request: basic or advanced. Along with the overall Google Terms of Use, there are usage limits specific to the Directions API.
In the case of Google Maps, Google owns the changes made to Google Maps. In contrast, the user and the OSM community own the edits done to OpenStreetMap. In the OpenStreetMap Community, expert volunteers around the world keep on updating the map as their environment changes.
You can use the Open Route Service https://openrouteservice.org/
It has an API (docs) that has a comprehensive description and is free.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With