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?
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?
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