I’m working with LangChain and LangSmith to test different prompts for my language model. Everything was working fine until I had to regenerate my OpenAI API key.
I updated the new key in my environment variables and confirmed it works by testing with OpenAI’s chat completion directly. I also went to LangSmith and updated the key in the playground settings under Secrets & API keys, plus verified it shows correctly in my organization settings.
But when I run arun_on_dataset in my Python script, I get this authentication error:
AuthenticationError("Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-M9XWA***************************************QpRt. You can find your API key at https://platform.openai.com/account/api-keys."})
The error shows my old API key prefix, not the new one I set everywhere. My code hasn’t changed at all, just the API key externally.
Where else might the old key be cached or stored? Any suggestions would be helpful!