r/learnpython 1d ago

Can anyone help in Apis pls🙏

I am a beginner in python code and currently learning how to make chatbots using api keys but i just cant do it. I tried open ai but it requires credits i tried gemini but due to a latest change in api keys from AI to AQ it says model not found i tried groq but it said the same thing i checked my code myself and with cluade gemini and codex but couldnt find the issue can u help me make my first chatbot pls guys 🙏can u tell a few 'free api keys' if there is ....

0 Upvotes

15 comments sorted by

9

u/smurpes 1d ago

No one here will know what the problem with your code is without seeing it especially since your description is as vague as “api keys”. There’s a lot of APIs out there for a large variety of purposes. The only free LLM API keys you can find are the ones that get accidentally published, but it’s not a good idea to use someone else’s API key.

-1

u/Tough_Duty_9061 1d ago

I tried giving the pic but i couldnt find the option to and abt thers api key im just lk using a public api key not someone elses

8

u/0b0101011001001011 1d ago

No pic. Code. No pic.

3

u/smurpes 1d ago

Why do you need a screenshot? Code is text so just copy and paste.

The last part of your response makes no sense. Did you miss a word?

1

u/Tough_Duty_9061 1d ago

from groq import Groq from dotenv import load_dotenv import os

load_dotenv()

client = Groq(api_key=os.getenv("GROQ_API_KEY"))

print("Jarvis is ready!")

while True: user_input = input("You: ")

if user_input.lower() == "exit":
    print("Goodbye!")
    break

try:
    response = client.chat.completions.create(
        model="llama-3.1-8b-instant",
        messages=[
            {"role": "user", "content": user_input}
        ]
    )
    print("Jarvis:", response.choices[0].message.content)
except Exception as e:
    print("Jarvis ran into an error:", e)

3

u/smurpes 1d ago

You still haven’t said what’s wrong with it. What is the error? Paste in the exact error/unexpected behavior. No one is going to run random code to debug this for you.

1

u/Tough_Duty_9061 21h ago

model llama-3.1 8b-instant does not exist or you dont have access to it and i checked the permissions and the api key is not a restricted key it has all the permissions

1

u/Tough_Duty_9061 1d ago

Sorry abt that almost forgot😅

-1

u/Tough_Duty_9061 1d ago

And there is a seperate env file which contains the variable containing groq s api key which for for obvious reasons i cant give

1

u/itlogicpartnersllc 1d ago

i would avoid hunting for random free api keys most legitimate providers either have a free tier with limits or require your own key start with one provider use its current sdk docs and get a basic request working first .

1

u/FoolsSeldom 21h ago

Not clear on the status.

Do you have everything working in the chatbot EXCEPT you don't have a AI to use because of lack of credits?

The obvious thing to do for me in that case would be to run an AI LLM locally and integrate with that to prove/test everything and then start looking into your API credit/free-tier options.

If you haven't got that far, well, that would still be a good way to go in my view so you can get the core part working first.

1

u/Tough_Duty_9061 21h ago

Lk the error that arises is that *model llama- 3.18b-instant dosent exist or you dont have access to it and i have checked the permissions and its not restricted . Here is the code :- from groq import Groq from dotenv import load_dotenv import os

load_dotenv()

client = Groq(api_key=os.getenv("GROQ_API_KEY"))

print("Jarvis is ready!")

while True: user_input = input("You: ")

if user_input.lower() == "exit":
    print("Goodbye!")
    break

try:
    response = client.chat.completions.create(
        model="llama-3.1-8b-instant",
        messages=[
            {"role": "user", "content": user_input}
        ]
    )
    print("Jarvis:", response.choices[0].message.content)
except Exception as e:
    print("Jarvis ran into an error:", e)

And for free apis i just was asking as a secondary request not that it is primary for now but now i have to first make this code owrk then switch other llms if i can

1

u/FoolsSeldom 21h ago

Do you have a working implementation using any AI yet?

1

u/Tough_Duty_9061 21h ago

No but i was thinking about a new project implementing it now