SkGroq | Use AI in Skript

Script SkGroq | Use AI in Skript v1.0.1

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

Supported Skript Version
  1. 2.15
Supported Minecraft Versions
  1. 1.21
  2. 26.1
SkGroq v1.0
An ultra-lightweight, seamless, and highly flexible Skript resource that connects your Minecraft server to the high-speed Groq API (supporting Llama 3.1 and other models).

Whether you want to create an interactive in-game server assistant, an advanced automated moderation flagger, or context-aware dynamic NPCs, SkGroq handles JSON parsing, web requests, and post-response formatting completely out of the box.

Requirements & Dependencies

To use SkGroq, your server must have the following installed:
  • Skript (v2.15.2+)
  • SkriptHTTP — The core web-hook framework used to handle asynchronous API calls. Download SkriptHTTP here
  • skript-reflect — Required dependency for SkriptHTTP to hook into Java web classes.
  • An active Groq API Key (Free or Paid tier).
  • Server internet connectivity enabled (to make outbound web requests).

Key Features

  • Sub-Second Responses: Powered by the Groq API network for blazing-fast in-game AI text generation.
  • Smart Context Injection: Send real-time game data (player locations, active world events, permissions) directly to the AI to ground its answers.
  • Modular Prompt Chaining: Mix and match temporary local instructions with hardcoded global server baselines and safety additions automatically.
  • Automatic Formatting Guardrails: Structurally forces the AI to avoid breaking your chat layouts by stripping out disruptive markdown or formatting tags.
  • Native In-Game Text Placeholders: Define simple text macros (like <discord> or <store>) in the config. The AI uses them naturally, and the Skript instantly parses them into fully functional, clickable, or colored text components for your players.
  • Built-in Developer Toolkit: Toggle on-the-fly request/response logging and JSON payload dumps in your console for seamless testing.

️How to Configure

All configurations are handled elegantly inside the options: block at the top of the Skript.

1. API Settings
  • api_key: Paste your API token generated from the Groq Developer Console.
  • model_name: The exact model identifier string (e.g., llama-3.1-8b-instant). Do not wrap this specific option value in quotation marks.
  • ai_temperature: Controls creativity. 0 is deterministic and strict, 1 is creative and conversational.
  • max_tokens: The maximum length allowed for the AI's response.

2. Prompt Chaining Configuration
  • default_system_prompt: The main personality blueprint for the AI when no custom prompt is sent via code.
  • addon_system_prompt: Global rules that are permanently appended to every single request (e.g., safety metrics, language filters, formatting restrictions).
  • placeholder_explanation: Explains your network text macros to the AI so it understands when and why to use them.

3. Text Macros (Placeholders)
  • placeholders: Define your tags using the "TAG->REPLACEMENT" format, separated by the word and. You can easily pass raw text, color codes (&b), or advanced JSON text components like <link:URL>...<reset>.

Usage

SkGroq exposes a single, incredibly robust function that handles all of the heavy lifting:

code_language.skript:
getAIResponse(message, context, system_prompt)

This can be used like:
code_language.skript:
set {_aiResponse} to getAIResponse(message, context, system_prompt)

Argument Behavior & Defaults:
1. message (Required): The user's input or question.
2. context (Optional): Use this to pass real-time game conditions dynamically.
3. system_prompt (Optional): Allows you to instantly change the AI's entire personality or job profile on a per-call basis.

⚠️ Note on Omitting Parameters:
Because of Skript's default parameter syntax, if you want to change the System Prompt but leave the Context as default, pass your custom context argument as [DEFAULT] to skip it smoothly.

⚡ Built-in Testing Command
The Skript includes a native, out-of-the-box utility command allowing you to instantly test your AI configuration directly from your chat window:

code_language.skript:
/testai <text>
  • Permission Required: skriptai.test
  • Behavior: Runs your entered text directly through the Skript using your live default options configurations and passes your context ("Player: %player%") straight into the engine.
Screenshot 2026-06-01 at 12.33.29 PM.png

Code Examples & Use Cases
Please note: These examples are intended to showcase application implementation guidelines. They are not thoroughly tested production Skripts and do not ship as baseline features of the SkGroq file itself.

Example 1: Basic Global Assistant (Standard Default Call)
Best for simple automated chat helpers responding to a command or event.
code_language.skript:
on chat:
    if message contains "how do I get help?":
        cancel event
        set {_reply} to getAIResponse(message)
        send "&a[Helper AI]: &f%{_reply}%" to player

Example 2: Dynamic Context-Aware Assistant
Pass player variables, current location, or game status directly into the context parameter so the AI knows exactly what's happening.
code_language.skript:
command /askai <text>:
    trigger:
        # Build live context data:
        set {_ctx} to "Player Name: %player%, Current World: %player's world%, Health: %player's health%/%player's max health%"
    
        # Fire request with custom context:
        set {_reply} to getAIResponse(arg-1, {_ctx})
        send "&e[SkGroq]: &f%{_reply}%" to player

Example 3: Changing Personalities on the Fly (Custom System Prompt)
Instantly pivot the engine's purpose. Switch it from a server guide into an elite dungeon monster, an NPC blacksmith, or a secret riddle master.
code_language.skript:
on right click on villager:
    if display name of target entity is "&6Dungeon Merchant":
        cancel event
        set {_npcPrompt} to "You are a greedy, mysterious dark-elf merchant trapped in a dungeon. Speak like a fantasy villain and look down on the player."
        set {_context} to "The player currently has %player's balance% coins."
    
        set {_reply} to getAIResponse("What do you sell?", {_context}, {_npcPrompt})
        send "&c[Merchant]: &f%{_reply}%" to player
Author
master_of_pooms
Downloads
24
Views
61
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from master_of_pooms

Latest updates

  1. Fix some issues

    This update fixes some issues and in the last one I accidentally leaked my groq key, it has been...