OPENAI_API_KEYS

how to get API keys to set this variable: OPENAI_API_KEYS

I could not proceed on learning LANGCHAIN module. Appreciate quick response/fix.

Hi @krishl

Could you please share the lab you are working on?

LangChain → Labs: Invoking LLMs

URL:
https://learn.kodekloud.com/user/courses/langchain/module/ae260750-791b-496c-991f-0d0333f61e40/lesson/0dfdfd01-a5b0-4e95-9ccd-49e5189bcd2e

As near as I can tell, this course is the continuation of the Introduction to OpenAI course. We tell you in that course how to get yourself set up with OpenAI, including how to register for an API key. So this course is a “bring your own API key” course – we don’t supply the key for you.

I have the active subscription of “KodeKloud AI”.
This Lab is from the Course “Lang Chain”

How to get API Keys to execute Notebook provided in the Labs?

This is discussed in the “Configuring the Development Environment” lecture at about @3:39. This course doesn’t support key proxies, so you can’t use KodeKey. The lecture goes through setting up a key with OpenAI.

Can i take formally, KodeKloud doesnt provide API access/keys for “any” Labs exercise for “any” courses under AI Playgrounds?

If so, This should have been explicitly mentioned while signing-up for subscription!

No, some of the labs indeed do implement the proxy protocol, and can use a “KodeKey” API key. This particular lab, which was finished before we had KodeKey, does not yet support it. I expect we’ll convert it to use key proxies, but we haven’t done it yet.

Actually, just got sample code taken directly from KodeKey and got it to run in the Jupyter environment of this lab. So it does in fact work. I ran code like this:

from openai import OpenAI

client = OpenAI(
    # I actually use a key from KodeKey here, which is subbed out for security...
    api_key="Sk-kkAI-xxxxxxxxxxxxxxxxxxxxxxxx_debef2be-yyyyyyyyyyyyyyyyyyyyy94b",
    base_url="https://kodekey.ai.kodekloud.com/v1"
)
response = client.chat.completions.create(
    model="openai/gpt-4o-2024-11-20",
    messages=[{"role": "user", "content": "In a single sentence, tell me why the sky is blue?"}]
)
print(response.choices[0].message.content)

This actually ran; so you should be able to use KodeKey api keys and have it work if you use similar syntax to do it. Not sure why I did not get it to work earlier – might have been my choice of model.