abi / screenshot-to-code

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
https://screenshottocode.com
MIT License
56.1k stars 6.89k forks source link

Error configuring ANTHROPIC API KEY in.env file #270

Closed bigfishnew closed 5 months ago

bigfishnew commented 5 months ago

I added "ANTHROPIC_API_KEY=s****" to the.env file

"No Anthropic API key found. Please add the environment variable ANTHROPIC_API_KEY to backend/.env"

bigfishnew commented 5 months ago

issue1 issue2

abi commented 5 months ago

@bigfishnew a couple of clarifications: is it definitely in backend/.env , not frontend/.env? In your screenshot, there's a " at the start, I'd recommend removing that.

abi commented 5 months ago

If you're still having problems, let me know.

bigfishnew commented 5 months ago

Yes, I put it in the "backend/.env" file image

abi commented 5 months ago

@bigfishnew can you get rid of the double quote (") at the start of your .env file?

And after we're done debugging this, please revoke this API key and use a new one so other people don't use your API key.

bigfishnew commented 5 months ago

image Without the double quotes, it still gives me an error. Another problem is that when I use Claude3, it also gives me an error if I don't set the OpenAI API Key in the Settings image

abi commented 5 months ago

@bigfishnew thanks for bringing the bug "when I use Claude3, it also gives me an error if I don't set the OpenAI API Key in the Settings" to my attention. I just fixed it.

Unfortunately, I'm not able to replicate your issue with the .env file. It works for me. Can you try directly modifying the code here: https://github.com/abi/screenshot-to-code/blob/7f44228a9582f6e39e8dbcee7598b86328ef7e74/backend/config.py#L6 and let me know if that fixes it?

bigfishnew commented 5 months ago

Just replace "ANTHROPIC_API_KEY" in the configuration file and there will be no error. But the console will raise an Error like this,"PermissionDeniedError: Error code: 403 - {'error': {'type': 'forbidden', 'message': 'Request not allowed'}}" I don't know if it has anything to do with me being in China. I don't know how to configure the agent in this software

abi commented 5 months ago

Yeah, I don't see China on this list: https://www.anthropic.com/supported-countries

You could try a VPN or proxy. I also just released Claude support to the paid version here: https://screenshottocode.com