This project demonstrates how to use the Groq SDK in both Node.js and Python environments. It includes example code for sending prompts to the Groq AI and handling responses. Rate Limits for Free Beta
The rate limits for the Free Beta are as follows:
ID | REQUESTS PER MINUTE | REQUESTS PER DAY | TOKENS PER MINUTE |
---|---|---|---|
gemma-7b-it | 30 | 14,400 | 15,000 |
mixtral-8×7b-32768 | 30 | 14,400 | 5,000 |
llama3-70b-8192 | 30 | 14,400 | 6,000 |
llama3-8b-8192 | 30 | 14,400 | 30,000 |
- Node.js (v12 or higher)
- Python (v3.7 or higher)
- Groq SDK
- Environment variables setup (see
.env.example
)
Create a .env
file in the root directory of your project and add the following environment variables:
GROQ_API_KEY=your_api_key_here
GROQ_MAX_TOKENS=100
GROQ_MODEL=your_model_here
To get started, follow these steps:
- Clone the repository using:
git clone https://github.com/Sagi-BA/groq.git
- Install the required dependencies by running:
npm install --omit=dev
-
Create a .env file in the root folder of the project. Use the env.example file as a template and add your environment variables.
-
Register on the Groq platform and create an API Key
-
To test the application, run the app.js file. You can change the starting JavaScript file by modifying the launch.json configuration.
To install the required dependencies, run the following:
- dotenv: ^16.4.5
- groq-sdk: ^0.3.3
- Groq
- python-dotenv
Here, I demonstrate how to use the GroqClass()
# pythoe example
import asyncio
from GroqClass import GroqClass # Corrected import statement
async def main():
mygroq = GroqClass()
userPrompt = "מי זה אנתוני הופקינס ?"
response = await mygroq.sendsendPrompt(userPrompt)
if response:
print(response.choices[0].message.content)
else:
print("Failed to get a response from Groq.")
if __name__ == "__main__":
asyncio.run(main())
// JavaScript example
// Import the GroqManager class using CommonJS syntax
const GroqClass = require("./GroqClass");
// Main function to send a user prompt and handle the response
async function main() {
const mygroq = new GroqClass();
const userPrompt = "Who is Anthony Hopkins?";
const response = await mygroq.sendPrompt(userPrompt);
if (response) {
console.log(response.choices[0]?.message?.content || "");
} else {
console.error("Failed to get a response from Groq.");
}
}
// Call the main function
main().catch(console.error);
This project is licensed under the ISC License. See the LICENSE file for details.