jasondotparse
jasondotparse10mo ago

Auth error

Hey, I created a new API key today, but no matter what I do, Langfuse keeps telling me it's invalid. According to the LS console everything seems in order. All I did was try to follow the "getting started" page first steps:
from langfuse import Langfuse
from datetime import datetime
from langfuse.model import InitialGeneration, Usage

os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-redacted"
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-redacted"

langfuse = Langfuse(
debug=True
)

generationStartTime = datetime.now()

generation = langfuse.generation(InitialGeneration(
name="summary-generation",
startTime=generationStartTime,
endTime=datetime.now(),
model="gpt-3.5-turbo",
modelParameters={"maxTokens": "1000", "temperature": "0.9"},
prompt=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Please generate a summary of the following documents \nThe engineering department defined the following OKR goals...\nThe marketing department defined the following OKR goals..."}],
completion="The Q3 OKRs contain goals for multiple teams...",
usage=Usage(promptTokens=50, completionTokens = 49),
metadata={"interface": "whatsapp"}
))
from langfuse import Langfuse
from datetime import datetime
from langfuse.model import InitialGeneration, Usage

os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-redacted"
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-redacted"

langfuse = Langfuse(
debug=True
)

generationStartTime = datetime.now()

generation = langfuse.generation(InitialGeneration(
name="summary-generation",
startTime=generationStartTime,
endTime=datetime.now(),
model="gpt-3.5-turbo",
modelParameters={"maxTokens": "1000", "temperature": "0.9"},
prompt=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Please generate a summary of the following documents \nThe engineering department defined the following OKR goals...\nThe marketing department defined the following OKR goals..."}],
completion="The Q3 OKRs contain goals for multiple teams...",
usage=Usage(promptTokens=50, completionTokens = 49),
metadata={"interface": "whatsapp"}
))
result: ERROR:langfuse:error uploading: [Langfuse] {"message":"Invalid public key"} (401) What am I missing?!
3 Replies
Marc
Marc10mo ago
Hi Jason, are you on the US data region? (us.cloud.langfuse.com) If yes, you need to set the host os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" Let me know if this fixed it for you, otherwise happy to have a closer look
jasondotparse
jasondotparse10mo ago
Yes, that worked, thank you!
Marc
Marc10mo ago
Perfect. Thanks for confirming