#๐Ÿ”’ Chatbot API confusion

58 messages ยท Page 1 of 1 (latest)

cursive shoal
#

Hii, I am working on a chatbot and i want to know how do i add api key,
in youtube i couldn't understand well.

errant canopyBOT
#

@cursive shoal

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

cursive shoal
#
from google import genai
from google.genai import types
import chatbot

client = genai.Client()
chat = client.chats.create(model="gemini-2.5-flash")

print("Your Character is ready! You can start chatting now. (Type 'exit' to quit)")

user_input = input("Enter your message to the character: ")

while user_input.lower() != 'exit':
    response = chat.send_message(chatbot.prompt)
    print(f"{chatbot.choice_name}: {response.text}\n")
    user_input = input("Enter your message to the character: ")
#

where do i add api and logic behind it
can anybody explain

waxen folio
#

@cursive shoal do you know what website gemini-2.5-flash is coming from? do you have an account there?

the API key is so that your code knows which account you are. Your API key is both a username and a password, so once you have it, never post it in the server!!!

cursive shoal
#

the youtuber didn't add an api key but his worked
how ?

waxen folio
#

he probably had the api key in a .env file

cursive shoal
#

I took a screenshot

cursive shoal
waxen folio
#

is that your computer, or the youtuber's?

cursive shoal
#

the youtuber's

waxen folio
waxen folio
#

on what website?

cursive shoal
#

got it

waxen folio
waxen folio
#

the page I linked to also shows you how to store the api key in a .env file

cursive shoal
waxen folio
# cursive shoal

you're showing a few characters of your API key. that's probably fine, but remember what I said about keeping your API key a secret.

cursive shoal
waxen folio
#

if you post your API key in Discord, a bot will probably take it and start using it, and you will have to pay for whatever they do.

waxen folio
cursive shoal
#

you want the code for it ?

waxen folio
#

It's a keyboard interrupt. Did you do control+c?

cursive shoal
#

where ?

waxen folio
#

it says at the bottom.

cursive shoal
#

let me try again without any interrupt

#

worked

#

thanks

waxen folio
#

yw

cursive shoal
#

the thing is i am learning to code and am new to this

#

that's why i am asking silly questions

waxen folio
#

it's okay
I hope you're enjoying the journey

cursive shoal
#

it's a fun activity to do and me and my friend are working on a roleplay chatbot

waxen folio
#

can I have the role of pope?

cursive shoal
#

where multiple characters can talk
but for the mvp, we decided to do just one-to-one

cursive shoal
waxen folio
#

yes

cursive shoal
#

what is it, i am asking this ?

#

never heard of this

waxen folio
#

anyway, don't worry about it

cursive shoal
waxen folio
#

what's your plan to handle multiple persons in the chat?

#

with the LLM?

cursive shoal
#

i was thinking of multiple chats for different character personality, the prompt will include the recent message from user and others and a whole summary of the chat that had happened

#

multiple chats in the sense like multiple api, one for one character

#

but mvp will be simple compared to that

#

it will have one-to-one

errant canopyBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.