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

Anthropic refusing to work after update #206

Closed
cristian-tapia opened this issue Dec 31, 2024 · 22 comments
Closed

Anthropic refusing to work after update #206

cristian-tapia opened this issue Dec 31, 2024 · 22 comments
Assignees
Labels
question Further information is requested

Comments

@cristian-tapia
Copy link

Hi. After updating to the lastest version (30/12/2024) the Anthropic node is giving me this error:

TypeError: "Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the X-Api-Key or Authorization headers to be explicitly omitted"

The API key is correctly configured inside the Griptape settings. Open AI is working without issues. Any hint?

Thank you.

@shhlife
Copy link
Collaborator

shhlife commented Dec 31, 2024

Hi @cristian-tapia - I tested this morning and it worked, can you double-check your api key, or send a copy of your workflow for me to reproduce?
image

@shhlife shhlife self-assigned this Dec 31, 2024
@cristian-tapia
Copy link
Author

Hi @cristian-tapia - I tested this morning and it worked, can you double-check your api key, or send a copy of your workflow for me to reproduce?
Captura de pantalla 2024-12-31 163911
Captura de pantalla 2024-12-31 164537

Hi, thanks for your quick reply. I'm attaching screenshots of two simple workflows. Thank you @shhlife

@shhlife
Copy link
Collaborator

shhlife commented Jan 1, 2025

Thank you for supplying the workflow. I've re-created a similar flow here (no extra prompts)

image

Can you double-check your Griptape Settings and make sure you've got an Anthropic API key defined?

image

@cristian-tapia
Copy link
Author

Hi @shhlife. Happy new year! Yes the API key is there and I even tried creating a new one, although the previous one is still working with no issues with the previous version of Griptape.
Captura de pantalla 2025-01-01 225403

@shhlife
Copy link
Collaborator

shhlife commented Jan 2, 2025

I can't seem to re-create the issue - can you show me the terminal where it's running into issues?

@cristian-tapia
Copy link
Author

Sure. There you go. Thank you!
Captura de pantalla 2025-01-03 005059

@shhlife
Copy link
Collaborator

shhlife commented Jan 3, 2025

That's so strange - the only thing I can think of is that the API key isn't correct - can you go into the settings, click in the Anthropic API Key area, do ctrl+a, ctrl+c and then go to a text file & do ctrl+v to paste it & make sure it's exactly what your api key should be?

@cristian-tapia
Copy link
Author

Hi @shhlife I did that, and they are identical. I tried updating the comfy nodes again and unfortunately the problem persists. All the other nodes (Open AI, Black Forest) work fine with their respective API keys.

@shhlife
Copy link
Collaborator

shhlife commented Jan 8, 2025

Okay, another thing to check.. in the terminal you're using to launch comfyui, can you check and see if you have an Anthropic API key set?

echo $env:ANTHROPIC_API_KEY

if you have one that doesn't match what's in comfyUI, that could be the issue.. you can remove it:

Remove-Item env:ANTHROPIC_API_KEY

and try again

@cristian-tapia
Copy link
Author

Hi @shhlife. I have checked in my terminal, and there is no environment variable named ANTHROPIC_API_KEY. The key is configured exclusively in the Griptape preferences within the ComfyUI GUI. Thanks for your continued help in resolving this issue!

@shhlife
Copy link
Collaborator

shhlife commented Jan 9, 2025

Okay, we're going to go hard core here. :)

can you create this python file and save it as anthropic_test.py:

import os

from anthropic import Anthropic
from dotenv import load_dotenv

load_dotenv()

client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
response = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    messages=[
        {"role": "user", "content": "How are you?"},
    ],
    max_tokens=100,
)
print(response.content[0].text)

then save your ANTHROPIC_API_KEY in a file called .env.

if you run this script with the python you're using for comfyUI, it should show a response from Anthropic.

for example, if you're using the standalone version, you should be able to do something like:

.\python_embeded\python.exe path\to\anthropic_test.py

@cristian-tapia
Copy link
Author

Hi @shhlife. It worked that way:

(temp_env) D:\ComfyFull\ComfyUI\temp_env\Scripts>python anthropic_test.py
I'm functioning well and ready to help! Thanks for asking. How are you today?

What should I do next? Thanks!

@cristian-tapia
Copy link
Author

Hi again @shhlife. I just noticed that the first call to Anthropic in my workflow works perfectly. However, the issue arises when I connect the "create agent" node to the "run image description" node. At that point, I encounter the API key error (which didn't happen before the upgrade)
Captura de pantalla 2025-01-09 182218

@shhlife
Copy link
Collaborator

shhlife commented Jan 13, 2025

Heya! sorry it's been a few days, was heads down getting some work done.

Interesting that it's working in your first workflow - but not in the Image Description node. Will check that outside of ComfyUI and see where the bug is

@shhlife
Copy link
Collaborator

shhlife commented Jan 13, 2025

Can you confirm which version of the Griptape Nodes you're running? Click with the Right mouse button and open the Griptape menu
image

@cristian-tapia
Copy link
Author

No problem, work first!. I'm using 2.1.09
Captura de pantalla 2025-01-13 201739

@shhlife
Copy link
Collaborator

shhlife commented Jan 27, 2025

If you update to the latest, are you still seeing the same issues?

@shhlife shhlife added the question Further information is requested label Jan 27, 2025
@shhlife
Copy link
Collaborator

shhlife commented Jan 31, 2025

please try again - re-open if this still isn't working. Tahnk you!

@shhlife shhlife closed this as completed Jan 31, 2025
@anyapixel
Copy link

Hey I'm just facing this same issues, my API is correct because it can run through the first agent and I'm getting an output but then the next agents are not working and i'm getting this same output: "Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the X-Api-Key or Authorization headers to be explicitly omitted"

Is it something to do with a queueing system with claude cause using openai didnt give me such issues? Please let me know how I could resolve this, cheers:)

@shhlife
Copy link
Collaborator

shhlife commented Jan 31, 2025

Ah! yes, I just fixed this last night - I discovered that the API key wasn't being saved in the environment properly - so the first agent would run, but then the second wasn't grabbing the key.

If you update your Griptape nodes, can you try it again?

@anyapixel
Copy link

Ahhh awesome thank you very much for the quick response, it works

@shhlife
Copy link
Collaborator

shhlife commented Jan 31, 2025

Fantastic! So sorry about the bug - it was a tricky one to solve, but I'm glad it works. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants