# R package broken

**URL:** https://ask.openrouteservice.org/t/r-package-broken/8063
**Category:** openrouteservice
**Created:** [September 24, 2026, 4:30pm UTC](https://ask.openrouteservice.org/t/r-package-broken/8063 "2026-09-24T16:30:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![llamasrcool369](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/llamasrcool369/32/4612_2.png) [@llamasrcool369](https://ask.openrouteservice.org/u/llamasrcool369)
#### Post date: [September 24, 2026, 4:30pm UTC](https://ask.openrouteservice.org/t/r-package-broken/8063/1 "2026-09-24T16:30:42Z")

</div>

A month ago it was working, now it doesn’t. Trying to understand the new API stuff, but it refuses to work still. It used to work so well, just put in the API key when prompted.

What I’ve tried: adding these lines of code before:

```auto
options(openrouteservice.url = "http://api.heigit.org/openrouteservice/v2/matrix")

ors_api_key("my_key") #regenerated btw

```

and at the end I get

Error: Openrouteservice API request failed  
[401] Authorization field missing  
Called from: process\_response(res, endpoint, output, simplifyMatrix)

So how do I fix it? And what if it were to change again, and then it would be difficult or even impossible to reproduce my results?

---

<div class="post-metadata">

### Author: ![adam](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/adam/32/8_2.png) [@adam](https://ask.openrouteservice.org/u/adam)
#### Post date: [September 25, 2026, 8:11am UTC](https://ask.openrouteservice.org/t/r-package-broken/8063/2 "2026-09-25T08:11:00Z")

</div>

Hi,

I just had a quick look and there are a couple of things that have been put in wrong in the request itself, and an issue relating to the creation and storage of the API key.

Firstly, the options part should be `options(openrouteservice.url = “[https://api.heigit.org/openrouteservice/](https://api.heigit.org/openrouteservice/)”)` - in particular note that it needs to be https rather than http else the authorization header gets stripped during a redirect.

Secondly, it seems that setting the api\_key through the `ors_api_key` method only works if the url of the service is set to be the old default [api.openroutservice.org](http://api.openroutservice.org) address. To use your API key with the “customised” APIi address, you will need to set the key using environment variables, e.g. `Sys.setenv(ORS_API_KEY=‘xxx’)`. Then you should be able to use the package in the same way as before.

---

<div class="post-metadata">

### Author: ![llamasrcool369](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/llamasrcool369/32/4612_2.png) [@llamasrcool369](https://ask.openrouteservice.org/u/llamasrcool369)
#### Post date: [September 25, 2026, 10:59am UTC](https://ask.openrouteservice.org/t/r-package-broken/8063/3 "2026-09-25T10:59:04Z")

</div>

Hey it finally works. The package should definitely be updated to have the right link for this. Part of my problem was also the url being the v2 matrix one and not the generic one.

---

<div class="post-metadata">

### Author: ![llamasrcool369](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/llamasrcool369/32/4612_2.png) [@llamasrcool369](https://ask.openrouteservice.org/u/llamasrcool369)
#### Post date: [September 25, 2026, 11:35am UTC](https://ask.openrouteservice.org/t/r-package-broken/8063/4 "2026-09-25T11:35:01Z")

</div>

New problem. The way my thing works is it splits about 3000 features into 179 batches of 18 features each. Trying to get minimum drive times and I’m taking the distance between a feature and 10 candidate locations. Problem: with the original 18 batches with adjustments to have 93 batches of 35 features, I get:

Error in `map()`:  
ℹ In index: 81.  
Caused by error:  
! Openrouteservice API request failed  
[6020] Unable to compute a distance/duration matrix: Search exceeds the limit of visited nodes.  
Run `rlang::last_trace()` to see where the error occurred.  
Called from: signal\_abort(cnd, .file)

Increasing the batch size further (say splitting into 41 batches with more features) I get a different error:

Error in `map()`:  
ℹ In index: 31.  
Caused by error:  
! Openrouteservice API request failed  
[6004] Request parameters exceed the server configuration limits. Only a total of 3500 routes are allowed.  
Run `rlang::last_trace()` to see where the error occurred.  
Called from: signal\_abort(cnd, .file)

Previously the 18 per batch was successful. How might I solve such a problem?
