Breach-OS / llm /client.py
Naman Gupta
added frontend for the project
f61eeae
raw
history blame contribute delete
949 Bytes
# client.py
# ---------
# This is the single place where we set up our connection to Groq's API.
# Every other file in llm/ imports `groq` and `model` from here — so if
# you ever want to swap to a different model or provider, just change it here.
import os
from openai import OpenAI
from dotenv import load_dotenv
# Load .env into os.environ so os.environ.get() picks up the keys.
# pydantic-settings reads .env into the Settings object only —
# it does NOT set os.environ, so we need this explicit call.
load_dotenv()
# Pull credentials from environment variables (.env file).
# Never hardcode keys in source code.
groq_api_key = os.environ.get("GROQ_API_KEY", "")
model = os.environ.get("MODEL_NAME", "llama-3.1-8b-instant")
# Groq's API is fully compatible with the OpenAI SDK — we just point it
# at Groq's base URL instead of OpenAI's.
groq = OpenAI(
base_url="https://api.groq.com/openai/v1",
api_key=groq_api_key,
)