As suggested by Mesa you can start by generating a route request which should provide you with an output json that you can parse to retrieve the route. You can then create a vector layer and add it to the map.
OSRM API Documentation provides all the necessary information (including example requests) to get you started.
Example:
http://router.project-osrm.org/route/v1/foot/13.388860,52.517037;13.397634,52.529407?geometries=geojson
Output:
{
"routes": [
{
"geometry": {
"coordinates": [
[
13.3888,
52.517033
],
[
13.388625,
52.518883
],
[
13.388024,
52.52175
],
[
13.388898,
52.521997
],
[
13.391643,
52.522074
],
[
13.391718,
52.522858
],
[
13.393549,
52.526228
],
[
13.392425,
52.528233
],
[
13.397631,
52.529432
]
],
"type": "LineString"
},
"legs": [
{
"summary": "",
"weight": 627.6,
"duration": 458.8,
"steps": [],
"distance": 1879.4
}
],
"weight_name": "routability",
"weight": 627.6,
"duration": 458.8,
"distance": 1879.4
}
],
"waypoints": [
{
"hint": "598JgGxZ5oQoAAAAOgAAAA8AAAAAAAAAeOI0QY6li0FoZYRAAAAAACgAAAA6AAAADwAAAAAAAAByoQAAAEzMAKlYIQM8TMwArVghAwEA3wr1yOx5",
"name": "Friedrichstraße",
"location": [
13.3888,
52.517033
]
},
{
"hint": "uZsTgLfVvIEOAAAADAAAAHMBAAAAAAAA4pzIQFu_j0CGdCVDAAAAAA4AAAAMAAAAcwEAAAAAAAByoQAAf27MABiJIQOCbswA_4ghAwIAnxD1yOx5",
"name": "Torstraße",
"location": [
13.397631,
52.529432
]
}
],
"code": "Ok"
}