Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Incorrect API key provided: sk-samplekey. #1415

Closed
ruanriqing opened this issue Jan 26, 2024 · 33 comments
Closed

[Bug]: Incorrect API key provided: sk-samplekey. #1415

ruanriqing opened this issue Jan 26, 2024 · 33 comments
Labels
proj-studio Related to AutoGen Studio.

Comments

@ruanriqing
Copy link

Describe the bug

when i use windows condapowershell to set apikey
Report:Error occurred while processing message: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-samplekey. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

how can i set

Steps to reproduce

No response

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

No response

@ruanriqing ruanriqing added the bug label Jan 26, 2024
@jackgerrits
Copy link
Member

What method are you using to set your key?

It looks like your API key is set to an example value rather than your own generated key. You can get your OpenAI key using your account here.

There's more documentation about how to configure your LLM endpoints here

@victordibia victordibia added the proj-studio Related to AutoGen Studio. label Jan 26, 2024
@victordibia
Copy link
Collaborator

victordibia commented Jan 26, 2024

The console message above suggests you are using autogenstudio.
You will need to verify the exact key in the agents in your workflow

  • if you have OPENAI_API_KEY env variable set and are using openai models, you can leave api key blank in the UI for your agent in the workflow
  • Set the api_key in the UI for agents in your workflow

You can see what keys your agents have in the UI by going to Build -> Workflow -> sender/receiver ... models

@Clinteastman
Copy link

I had this problem. Delete all your "models" and re-add them with your correct keys.

@Elle-73
Copy link

Elle-73 commented Jan 26, 2024

hi, I have the same issue. I tried deleting the models and re-added them, I tried new API keys. I also specify the key in env and within the model. But i still get the same error.

@mgredenberg
Copy link

Same problem here with MacOS. API-Key env variable (OPENAI_API_KEY) was set correctly before creating virtual environment (Conda) and installing autogen studio.
Also tried to delete all models and add the GPT-4 Model (with and without entering the API Key). Result => Always this error:
Error occurred while processing message: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-samplekey. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

@cevatkerim
Copy link

same here. adding the models again or even having the env variable doesnt help.

@victordibia
Copy link
Collaborator

victordibia commented Jan 26, 2024

Thanks for noting this.

If you are seeming sk-samplekey, this suggests your workflow is using the default agent key. You can modify this by.

  • Build -> Models -> create a new model, put in your model name and api key
  • Workflow .. go to your workflow, click to edit ... click each agent in the workflow ... remove the model there and add the model you defined in the previous step.

Go to playground ...

IMPORTANT NOTE: Editing your model does not automatically update your workflow. Each time you edit your model, you will need to manually update your workflow (i.e., remove the previous model on your agent in the workflow and add the new model.).

ags_apikey_addmodel.mov

Create new session .. select your updated workflow ...

Also ensure you are on the latest version of autogenstudio

  • pip uninstall autogenstudio
  • pip install -U autogenstudio
  • autogenstudio ui --appdir newdir

the last command tells autogenstudio to use newdir to store files including creating a new db.

@mgredenberg
Copy link

victordibia: That doesn't work for me. I did it EXACTLY like in your video.

  1. Adding a new Model without entering the API key and I tried also adding a new Model AND entering the API Key.
  2. Changed the model in the Agent
  3. Tried playground with a new session => Always the same error (sk-samplekey) ;-(

@mgredenberg
Copy link

victordibia: And as I already mentioned. OPENAI_API_KEY env variable is set correctly and available in the Conda environment.

@victordibia
Copy link
Collaborator

Thanks.

Two things.

I am investigating a possible bug where the api_key is not read from the env variable correctly in v 0.0.35a (it seems to be set to "" and not read). Can you do a pip install -U autogenstudio to upgrade to latest v0.0.37a.

In my video, I do not put in the api key in the model, but I mention in the instructions that you need to put in both the model and api key. Let me know if you are still having issues.

@mgredenberg
Copy link

  1. I did the upgrade and restarted autogen studio:
    Installing collected packages: autogenstudio
    Attempting uninstall: autogenstudio
    Found existing installation: autogenstudio 0.0.35a0
    Uninstalling autogenstudio-0.0.35a0:
    Successfully uninstalled autogenstudio-0.0.35a0
    Successfully installed autogenstudio-0.0.37a0

  2. I removed all models and added only the GPT4 Model WITH Api Key

Bildschirmfoto 2024-01-26 um 23 56 31
  1. I removed the (old) model from the agent and added the new created one:
Bildschirmfoto 2024-01-26 um 23 57 51
  1. Started a new Session in Playground and tried it out:
Bildschirmfoto 2024-01-27 um 00 00 27

Always the same error!

@SaschaFitzner
Copy link

I do the same like mgredenberg, but nothing works with version v0.0.35a and v0.0.37a

@swojoe
Copy link

swojoe commented Jan 27, 2024

Getting the same issue.
I've tried:

  • Cleared Cache
  • Tried removing and adding models
  • Created new API key
  • Blew away all my environments and created new ones
  • Upgraded to v0.0.37a

@Cantstop2023
Copy link

Had the same issues but figured it out, not sure if it would work for you guys.

Create a new model then delete it.

Use the existing model gpt-4-1106-preview - with your api-key

Then make sure to close everything down, reopen it using a new port and magically worked

@suredream
Copy link

same here. Try what @Cantstop2023 describe but no magic happened.

@victordibia
Copy link
Collaborator

victordibia commented Jan 28, 2024

Hi, @suredream

Here are a few things I would suggest.

Update AutoGen Studio

First, let us ensure you are on the latest version of autogenstudio

  • pip uninstall autogenstudio
  • pip install -U autogenstudio
  • autogenstudio ui --appdir newdir

the last command tells autogenstudio to use newdir to store files including creating a new db.

Set Model and API Key in UI

If you are seeming sk-samplekey, this suggests that the agenst in your workflow is using the default agent key sk-samplekey. You can modify this by.

  • Build -> Models -> create a new model, put in your model name and api key
  • Workflow .. go to your workflow, click to edit ... click each agent in the workflow ... remove the model there and add the model you defined in the previous step.

Go to playground ...
Create new session .. select your updated workflow ...

IMPORTANT NOTE: Editing your model does not automatically update your workflow. Each time you edit your model, you will need to manually update your workflow (i.e., remove the previous model on your agent in the workflow and add the new model.).

ags_apikey_addmodel.mov

@notedit
Copy link

notedit commented Jan 28, 2024

same here

@suredream
Copy link

thanks. @victordibia . Not working.

@quanhuiyuan
Copy link

@victordibia
hello! I read all Q&A above and I followed your steps strictly, but I still didn't fix it. I found my problem changed from
"Error occurred while processing message: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-samplekey. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}"
to "Error occurred while processing message: Error code: 401 - {'statusCode': 401, 'message': 'Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com/), or have expired.'}"
could you help me with it?
Thank you for your time!!!

@Cantstop2023
Copy link

Cantstop2023 commented Jan 29, 2024

I figured it out cause it stopped working for me again.

Before proceeding with anything make sure you do the following in powershell type in n-
$env:OPENAI_API_KEY='your_api_key_here'

Another thing i realised is that Group Chat does not work but Two Agents has no issue

The in the powershell type in -
$env:OPENAI_API_KEY

This should then show your API KEY back to you.

Once this is done run autogen -

autogenstudio ui --port 8080

Go to Model and delete all of them except -
gpt-4-1106-preview

Update - gpt-4-1106-preview - with your api key

Will use one of the current workflows -
General Agent Workflow

Once you have clicked on -
General Agent Workflow
Then select -
primary_assistant
delete the model then re-add it.

The go to Playground and select New and select one of the green option Stock Price / Sine Wave

If the API KEY error comes again just open another powershell type - $env:OPENAI_API_KEY and see if it stuck as when i opened autogen studio it did dissapear and i just run it again it worked.

@rbanks1
Copy link

rbanks1 commented Jan 29, 2024

I'm having the same problem. I decided to try Autogen Studio after I'd been playing around with a code sample for Semantic Kernel. I'd assumed the "sk" in "sk-samplekey" was something to do with Semantic Kernel, maybe some weird thing it did on install. Anyone else seeing this bug after also installing Semantic Kernel?

@victordibia
Copy link
Collaborator

victordibia commented Jan 29, 2024

@rbanks1,

What happens exactly when you run the following:

  • pip uninstall autogenstudio
  • pip install -U autogenstudio
  • autogenstudio ui --port 8081 --appdir newdir

Note ... note the --appdir newdir . (specifying appdir ensures that autogenstudio creates a new dir to store files. This should cause autogenstudio to reinitialize a new db which has no default keys. )

autogenstudio ui --port 8081 --appdir newdir

Do you still see the sk-samplekey error?

@rbanks1
Copy link

rbanks1 commented Jan 29, 2024

Actually, I did the same thing you originally suggested (deleting the models and workflows) and that seems to have fixed it.

@IainKainos
Copy link

I made these changes and now the error reads;

Error occurred while processing message: 'AgentFlowSpec' object has no attribute 'name'

I've checked everything is named, all of the elements are new and I am using the --appdir --newdir?

Any ideas?

@victordibia
Copy link
Collaborator

victordibia commented Jan 30, 2024

@IainKainos ,

The error suggests you might be on an older version and this bug has been fixed in recent versions.
Current version in 0.0.42a

What is your autogen studio version?
pip show autogenstudio

To upgrade
pip install -U autogenstudio

@suredream
Copy link

suredream commented Jan 31, 2024

@victordibia update to 0.0.42a, remove app_dir and start over. Same error:

The model `gpt-4-1106-preview` does not exist or you do not have access to it

github-merge-queue bot pushed a commit that referenced this issue Feb 6, 2024
…indows Testing ] (#1475)

* support groupchat, other QOL fixes

* remove gallery success toast

* Fix #1328. Add CSVLoader component and related support for rendering CSV files. Add download link in the modal for appropriate file types including CSV, Code, and PDF.

* add name and description field to session datamodel

* Update website/blog/2023-12-01-AutoGenStudio/index.mdx

Co-authored-by: Chi Wang <[email protected]>

* sanitize llmconfig, remove additional fields

* improve models UX, only modify models from model tab.

* readme updates

* improve db defaults

* improve ui hover behavior and add note on models

* general qol updats

* add support for returning summary_method

* use ant design tables

* icon and layout updates

* css and layout updates

* readme updates and QOL updates

* fix bug where empty string is used as apikey #1415

* add speaker selection to UI #1373

* Fixed a bug that localAgent updates were not synchronized between GroupChatFlowSpecView and AgentFlowSpecView.

* Fixed a bug in Agent Specification Modal that caused localAgent updates to remain in state when closing a modal other than onOk.

* Fixed a bug that the updated Agent Specification Modal was not saved when the content of FlowConfigViewer Modal was changed after the Agent Specification Modal was updated when an updatedFlowConfig was created using localFlowConfig.

* add version to package

* remove sample key

* early support for versions table and testing models

* Add support for testing model when created #1404

* remove unused imports, qol updates

* fix bug on workflowmanager

* make file_name optional in skills datamodel

* update instructions on models

* fix errors from merge conflict with main

* santize workflow before download

* add support for editing skills in full fledged editor (monaco) #1442

* fix merge artifacts

* Fix build command for windows

Replaced && to & to continue execution when the 'ui' folder doesn't exist and also suppressed error "The system cannot find the file specified."

* Fix setup instructions

The config file starts with a dot (according to gatsby-config.ts).

* Throw error if env file doesn't exist

Otherwise the app will not work (issue very hard to trace)

* version bump

* formattin gupdates

* formatting updates

* Show warning instead of error if env config file doesn't exist

Fix: #1475 (comment)

* add rel noopener to a tags

* formating updates

* remove double section in readme.

* update dev readme

* format update

* add default autoreply to agent config datamodel

* add check for empty messages list

* improve groupchat behavior, add sender to list of agents

* update system_message defaults to fit autogen default system message #1474

* simplify response from test_model to only return content, fix serialization issue in #1404

* readme and other formatting updates

* add support for showing temp and default auto reply #1521

* formatting updates

* formating and other updates

---------

Co-authored-by: Paul Retherford <[email protected]>
Co-authored-by: Chi Wang <[email protected]>
Co-authored-by: junkei_okinawa <[email protected]>
Co-authored-by: Christopher Pereira <[email protected]>
@sonichi
Copy link
Contributor

sonichi commented Feb 11, 2024

I hope this issue is resolved now. If not, please consider joining an office hour on discord.

@engineerakshat
Copy link

engineerakshat commented Feb 12, 2024

I am on version 0.0.44.

I have just one model gpt-4-1106-preview.
tried with env var and keeping API KEY in UI as blank.
tried with saving API KEY in UI while having env variable.
but no luck.

I accessed sqlite separately, it is saving the API keys properly for all agents and workflow.
But while using the workflow on playground, getting this error:

Error occurred while processing message: Error code: 401 - {'error': {'message': 'Incorrect API key provided: ********. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

I tried downloading the workflow, sharing a snippet:

"config": {
            "name": "Group Manager",
            "llm_config": {
                "config_list": [
                    {
                        "id": "b566c825-2848-4ca4-9e76-d5182dbb9b68",
                        "user_id": "default",
                        "timestamp": "2024-02-12T18:47:06.616192",
                        "model": "gpt-4-1106-preview",
                        "api_key": "********",
                        "base_url": null,
                        "api_type": null,
                        "api_version": null,
                        "description": ""
                    }
                ],
                "temperature": 0.1,
                "cache_seed": null,
                "timeout": null
            }

@engineerakshat
Copy link

@victordibia would you be able to help on this one?
It really got me stuck.

@victordibia
Copy link
Collaborator

@engineerakshat ,

That error suggests that one or more of your agents have their key set to ******.
What you can do ...

  • Build -> Model ... Create a model config and test it to verify that it works. Note that simply creating a new model here does not attach it to your config.
  • Build -> Workflow ... Go through each agent config, remove the previous models and then add the new model you created in the previous step. If your workflow is a groupchat, you will have to do this for each agent in your group chat, and also for the groupchat agent itself.
  • Playground -> new session, select the workflow you just updated.
groupchat_.mp4

@engineerakshat
Copy link

Solved!
I deleted all the models, agents and workflows.
And did everything from scratch.

Thank you for help!

@majacinka @victordibia

@GihanMora
Copy link

This issue persists for me. Any solution? Tried the steps above mentioned but no luck..

@engineerakshat
Copy link

This issue persists for me. Any solution? Tried the steps above mentioned but no luck..

Try following steps which worked for me:

  1. Delete all models, agents and workflows.
  2. Turn off the autogen studio
  3. Start autogen studio
  4. Create required models, agents and workflows(avoid editing them)

Should work fine then.

whiskyboy pushed a commit to whiskyboy/autogen that referenced this issue Apr 17, 2024
…indows Testing ] (microsoft#1475)

* support groupchat, other QOL fixes

* remove gallery success toast

* Fix microsoft#1328. Add CSVLoader component and related support for rendering CSV files. Add download link in the modal for appropriate file types including CSV, Code, and PDF.

* add name and description field to session datamodel

* Update website/blog/2023-12-01-AutoGenStudio/index.mdx

Co-authored-by: Chi Wang <[email protected]>

* sanitize llmconfig, remove additional fields

* improve models UX, only modify models from model tab.

* readme updates

* improve db defaults

* improve ui hover behavior and add note on models

* general qol updats

* add support for returning summary_method

* use ant design tables

* icon and layout updates

* css and layout updates

* readme updates and QOL updates

* fix bug where empty string is used as apikey microsoft#1415

* add speaker selection to UI microsoft#1373

* Fixed a bug that localAgent updates were not synchronized between GroupChatFlowSpecView and AgentFlowSpecView.

* Fixed a bug in Agent Specification Modal that caused localAgent updates to remain in state when closing a modal other than onOk.

* Fixed a bug that the updated Agent Specification Modal was not saved when the content of FlowConfigViewer Modal was changed after the Agent Specification Modal was updated when an updatedFlowConfig was created using localFlowConfig.

* add version to package

* remove sample key

* early support for versions table and testing models

* Add support for testing model when created microsoft#1404

* remove unused imports, qol updates

* fix bug on workflowmanager

* make file_name optional in skills datamodel

* update instructions on models

* fix errors from merge conflict with main

* santize workflow before download

* add support for editing skills in full fledged editor (monaco) microsoft#1442

* fix merge artifacts

* Fix build command for windows

Replaced && to & to continue execution when the 'ui' folder doesn't exist and also suppressed error "The system cannot find the file specified."

* Fix setup instructions

The config file starts with a dot (according to gatsby-config.ts).

* Throw error if env file doesn't exist

Otherwise the app will not work (issue very hard to trace)

* version bump

* formattin gupdates

* formatting updates

* Show warning instead of error if env config file doesn't exist

Fix: microsoft#1475 (comment)

* add rel noopener to a tags

* formating updates

* remove double section in readme.

* update dev readme

* format update

* add default autoreply to agent config datamodel

* add check for empty messages list

* improve groupchat behavior, add sender to list of agents

* update system_message defaults to fit autogen default system message microsoft#1474

* simplify response from test_model to only return content, fix serialization issue in microsoft#1404

* readme and other formatting updates

* add support for showing temp and default auto reply microsoft#1521

* formatting updates

* formating and other updates

---------

Co-authored-by: Paul Retherford <[email protected]>
Co-authored-by: Chi Wang <[email protected]>
Co-authored-by: junkei_okinawa <[email protected]>
Co-authored-by: Christopher Pereira <[email protected]>
@gagb gagb closed this as completed Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proj-studio Related to AutoGen Studio.
Projects
None yet
Development

No branches or pull requests