PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Advanced Paste with AI always shows: Invalid API key or endpoint

Open michabbb opened this issue 1 year ago • 4 comments

Microsoft PowerToys version

v0.81.0

Installation method

PowerToys auto-update

Running as admin

Yes

Area(s) with issue?

Advanced Paste

Steps to reproduce

setup an openai api token, use any prompt to change the copied text

✔️ Expected Behavior

get result from openai

❌ Actual Behavior

power-toys always says: Invalid API key or endpoint

  • the token is valid and created fresh, copy&paste without any whitespaces
  • there is balance on my account

without knowing which endpoint is used here, I don´t know how to debug this.

Other Software

No response

michabbb avatar May 22 '24 16:05 michabbb

There might be something useful in the logs for Advanced Paste. /bugreport

jaimecbernardo avatar May 22 '24 20:05 jaimecbernardo

okay, found an error in the logs:

[18:43:12.5813920] [Error] AICompletionsHelper::AIFormatString
    GetAICompletion failed
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.
Status: 401 (Unauthorized)

Content:
{
  "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": null
  }
}

so, I don´t know why "model.request" is needed here. but it looks like the minimum scopes that must be set are these:

image

Usually, a "read-only" token should be enough when talking to any model. i would be happy if the author of "Advanced Paste" could clarify which minimum settings are needed and also put that info on the docs page.

michabbb avatar May 22 '24 23:05 michabbb

@craigloewen-msft , any input here?

jaimecbernardo avatar May 24 '24 13:05 jaimecbernardo

My fault. I don´t know what you can do with a "read-only" token, but you need at least the scopes you see in my screenshot to chat with the model. I guess I misunderstood the definition of "read-only" here 😏

Note: if you change the scopes of your key, it can take several minutes till these changes become active. That´s annoying because you cannot test these scopes by trial and error. It´s faster to delete the old key and create a new one because the new one is active immediately.

Anyway: It´s still a good idea to let the user know, which scopes the key needs 😏

michabbb avatar May 26 '24 21:05 michabbb