microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
110.24k stars 6.49k forks source link

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

Closed michabbb closed 2 months ago

michabbb commented 4 months ago

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

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

Other Software

No response

jaimecbernardo commented 4 months ago

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

michabbb commented 4 months ago

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.

jaimecbernardo commented 4 months ago

@craigloewen-msft , any input here?

michabbb commented 4 months ago

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 😏