Na aula 4 - Criando contador de tokens, estou recebendo alguns erros. Gostaria de entender o que estou fazendo de errado.
link do git: https://github.com/James-pd4/python-gemini/tree/master/curso_gemini
Meu código :
import google.generativeai as genai
MODELO_FLASH = "gemini-2.0-flash"
MODELO_PRO = "gemini2.0-pro"
CUSTO_ENTRADA_FLASH = 0.075
CUSTO_SAIDA_FLASH = 0.30
CUSTO_ENTRADA_PRO = 3.5
CUSTO_SAIDA_PRO = 10.50
modelo_flash = genai.get_model(f"models/{MODELO_FLASH}")
limites_modelo_flash = {
"tokens_entrada": modelo_flash.input_token_limit,
"tokens_saida": modelo_flash.output_token_limit
}
print(f"Limites do modelo flash são: {limites_modelo_flash}")
Mensagem de erro:
raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS)
google.auth.exceptions.DefaultCredentialsError:
No API_KEY or ADC found. Please either:
- Set the GOOGLE_API_KEY
environment variable.
- Manually pass the key with genai.configure(api_key=my_api_key)
.
- Or set up Application Default Credentials, see https://ai.google.dev/gemini-api/docs/oauth for more information.