Invalid authentication token. Even with newly generated cloud API key. #39

Closed
opened 2026-02-16 00:16:41 -05:00 by yindo · 9 comments
Owner

Originally created by @ggjx22 on GitHub (Mar 8, 2024).

Hello Team,

Really like your work on LlamaParse. The web app is working fine for PDF parsing but not the package.
Even when a new cloud API key is used, I got the same error.

import nest_asyncio
nest_asyncio.apply()

from llama_parse import LlamaParse
import os
from dotenv import load_dotenv

load_dotenv()
LLAMA_CLOUD_API_KEY = os.getenv("LLAMA_PARSE_API")

parser = LlamaParse(api_key=LLAMA_CLOUD_API_KEY, result_type='markdown')

try:
    document = parser.load_data(file_path='data/file.pdf')
except Exception as error:
    print(f'An error occurred: {error}')
Error while parsing the PDF file 'data/filepdf': Failed to parse the PDF file: {"detail":"Invalid authentication token"}
An error occurred: Failed to parse the PDF file: {"detail":"Invalid authentication token"}
Originally created by @ggjx22 on GitHub (Mar 8, 2024). Hello Team, Really like your work on LlamaParse. The web app is working fine for PDF parsing but not the package. Even when a new cloud API key is used, I got the same error. ```python import nest_asyncio nest_asyncio.apply() from llama_parse import LlamaParse import os from dotenv import load_dotenv load_dotenv() LLAMA_CLOUD_API_KEY = os.getenv("LLAMA_PARSE_API") parser = LlamaParse(api_key=LLAMA_CLOUD_API_KEY, result_type='markdown') try: document = parser.load_data(file_path='data/file.pdf') except Exception as error: print(f'An error occurred: {error}') ``` ``` Error while parsing the PDF file 'data/filepdf': Failed to parse the PDF file: {"detail":"Invalid authentication token"} An error occurred: Failed to parse the PDF file: {"detail":"Invalid authentication token"} ```
yindo closed this issue 2026-02-16 00:16:41 -05:00
Author
Owner

@anoopshrma commented on GitHub (Mar 9, 2024):

Can you check if you are getting the correct API key from env.

@anoopshrma commented on GitHub (Mar 9, 2024): Can you check if you are getting the correct API key from env.
Author
Owner

@ggjx22 commented on GitHub (Mar 9, 2024):

Hmm I'm not sure what's going on. I switch to a Mac workstation with the exact piece of code in my issue above and the parser is working.

@ggjx22 commented on GitHub (Mar 9, 2024): Hmm I'm not sure what's going on. I switch to a Mac workstation with the exact piece of code in my issue above and the parser is working.
Author
Owner

@anoopshrma commented on GitHub (Mar 9, 2024):

I think it could be that env was not being picked correctly on your previous setup. Try printing it and check if it is getting correct API key or not.

@anoopshrma commented on GitHub (Mar 9, 2024): I think it could be that env was not being picked correctly on your previous setup. Try printing it and check if it is getting correct API key or not.
Author
Owner

@RaniBgz commented on GitHub (Mar 13, 2024):

Bumping this because I am getting the same issue here.
Using a valid OpenAI key, initializing both in the environment as 'LLAMA_CLOUD_API_KEY', and passing it as a parameter to Llama Parse, but I get:

    raise Exception(f"Failed to parse the PDF file: {response.text}")
Exception: Failed to parse the PDF file: {"detail":"Invalid authentication token"}

I am on Linux (Ubuntu), in a conda environment using Python 3.9.
The call to openAI models works with this api key.
In the tutorials, I also see the llama api key as looking like "llx...", whereas all of my keys from OpenAI start with "sk-...". Is there a different place to generate a llama key, or should a regular OpenAI key work?

Thanks for any info!

@RaniBgz commented on GitHub (Mar 13, 2024): Bumping this because I am getting the same issue here. Using a valid OpenAI key, initializing both in the environment as 'LLAMA_CLOUD_API_KEY', and passing it as a parameter to Llama Parse, but I get: ``` raise Exception(f"Failed to parse the PDF file: {response.text}") Exception: Failed to parse the PDF file: {"detail":"Invalid authentication token"} ``` I am on Linux (Ubuntu), in a conda environment using Python 3.9. The call to openAI models works with this api key. In the tutorials, I also see the llama api key as looking like "llx...", whereas all of my keys from OpenAI start with "sk-...". Is there a different place to generate a llama key, or should a regular OpenAI key work? Thanks for any info!
Author
Owner

@anoopshrma commented on GitHub (Mar 13, 2024):

LlamaCloud keys are totally different from openai keys!

Llamacloud api keys are used to parse pdf files!
You can generate one here: cloud.llamaindex.ai

@anoopshrma commented on GitHub (Mar 13, 2024): LlamaCloud keys are totally different from openai keys! Llamacloud api keys are used to parse pdf files! You can generate one here: cloud.llamaindex.ai
Author
Owner

@RaniBgz commented on GitHub (Mar 13, 2024):

HAH!
I am not familiar with the llama environment yet, so I was following the generic llama-index "getting started" guide, and trying to use an OpenAI key (https://docs.llamaindex.ai/en/stable/getting_started/starter_example.html)

Thank you so much for the link anoopshrma

-Rani

@RaniBgz commented on GitHub (Mar 13, 2024): HAH! I am not familiar with the llama environment yet, so I was following the generic llama-index "getting started" guide, and trying to use an OpenAI key (https://docs.llamaindex.ai/en/stable/getting_started/starter_example.html) Thank you so much for the link anoopshrma -Rani
Author
Owner

@anoopshrma commented on GitHub (Mar 13, 2024):

Sure no worries. Happy to help! Feel free to post any issue 💪

@anoopshrma commented on GitHub (Mar 13, 2024): Sure no worries. Happy to help! Feel free to post any issue 💪
Author
Owner

@me-jordankim commented on GitHub (May 23, 2024):

I got same error, but I solved this.

When I set api_key={My OpenAI API key} like the document said, I got an error.
Just change api_key={My Llama cloud API key}. then the problem will be solved.
(But I don't know why either. Maybe the document is wrong?)

You can get Llama Cloud API key in here: https://cloud.llamaindex.ai/

@me-jordankim commented on GitHub (May 23, 2024): I got same error, but I solved this. When I set `api_key={My OpenAI API key}` like the document said, I got an error. Just change `api_key={My Llama cloud API key}`. then the problem will be solved. (But I don't know why either. Maybe the document is wrong?) You can get Llama Cloud API key in here: https://cloud.llamaindex.ai/
Author
Owner

@JeroCuevas commented on GitHub (Mar 8, 2025):

It's because it doesn't work with LlamaCloud (EU), you need to change this.

@JeroCuevas commented on GitHub (Mar 8, 2025): It's because it doesn't work with LlamaCloud (EU), you need to change this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#39