Restricted API key misses model.request scope

I have a restricted API Key that allows only ChatCompletions and I’m getting this error

401 - {
“error”: {
“message”: “You have insufficient permissions for this operation. Missing scopes: model.request. Check that you have the correct role in your organization (Reader, Writer, Owner) and project (Member, Owner), and if you’re using a restricted API key, that it has the necessary scopes.”,
“type”: “invalid_request_error”,
“param”: null,
“code”: “missing_scope”
}
}

It’s weird because when I select only ChatCompletions permissions, Request permissions are automatically set to “Mixed”, which I assume covers Request.

When we created the key we had broader permissions and everything worked but once we wanted to restrict them we started getting this.

Looks like OpenAI folks already patched this ( Topic Missing scopes: model.request on restricted API key #11 ) but still doesn’t work on our end. Is there any solution?

Hi and welcome to the community!

I have pinged the team to take a look.

We have seen similar reports here before. Can you try creating a key with all permissions first, and then remove all permissions except the one you actually need?

Hi, thanks for the quick answer.

I’ve tried with a new one and it works, so I discard org. problems.

I’ve noticed this, though (see screenshot)

If I select Request in model capabilities, I can see model.request in the selected permissions.

On the contrary, when I just choose just ChatCompletions I just see api.model.chat_completions.request.

Looks like there’s a bug here :sweat_smile:

Hi there!

Is there any news around this?

Thanks in advance :slight_smile:

This is actually expected behavior - chat completions only requires

api.model.chat_completions.request

scope, while api.model.request means the request permission for all the endpoints under that section. So if the goal is to only allow access to chat completions, choose “Request” for the chat completions endpoint, rather than the whole section.

Just tested directly via API call and it works with the restricted permissions… So it must be something the framework I’m using (SpringAI) is doing in the background… I’ll raise this in their github issues :slight_smile:

Thanks for checking!

Glad I could help!
Feel free to circle back if there’s something else at play here.