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

Issue: 401 Unauthorized when following langsmith tracing instructions #666

Closed
sahellebusch opened this issue May 7, 2024 · 11 comments
Closed

Comments

@sahellebusch
Copy link

Issue you'd like to raise.

Added my first project and API keys to test out the tracing functionality. Followed the instructions in the docs and set the following values:

LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY="REDACTED"

And I keep getting the following:

Error: Failed to batch create run: 401 Unauthorized {"detail":"Invalid token"}

Everything else works. The model calls and responds correctly. Any advice here?

Suggestion:

No response

@hinthornw
Copy link
Collaborator

Could you confirm that if you create a new API key in the app and re-run this code it still doesn't work?

@sahellebusch
Copy link
Author

I've already created a new API key twice now.

@hinthornw
Copy link
Collaborator

What is the actual code you are running?

@sahellebusch
Copy link
Author

sahellebusch commented May 9, 2024

Omitting some details for brevity.

this.openAI = new ChatOpenAI({
      openAIApiKey: process.env.OPENAI_API_KEY,
      modelName: 'gpt-4-turbo-preview',
      temperature: 0.8,
    });

const prompt = await hub.pull<ChatPromptTemplate>(
      'seanhellebusch/[redacted]',
    );

    const res = await prompt
      .pipe(this.openAI)
      .pipe(this.outputParser)
      .invoke({ input, data: this.getDataXml() });

@VINHTRAN-VICIDEV
Copy link

I have the same problem and I think the cause is we haven't added the payment yet?

@hinthornw
Copy link
Collaborator

No payment is required to send traces to langsmith.

@sahellebusch are you including the literal '"' quotes in your api key?

@sahellebusch
Copy link
Author

@hinthornw - nope.

@03balogun
Copy link

Having the same issue.

@VINHTRAN-VICIDEV
Copy link

thanks @hinthornw, it's working

@sahellebusch
Copy link
Author

@VINHTRAN-VICIDEV - Does your issues relate to mine at all? If yes, how did you resolve?

@sahellebusch
Copy link
Author

Welp, not sure where I copy/pasted it from but it's the "HUB" api key, needs to just be LANGCHAIN_API_KEY and it all works just fine.

https://github.com/langchain-ai/langsmith-sdk/blob/main/js/src/client.ts#L445

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

No branches or pull requests

4 participants