Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/groq-reference-architecture

@0d57af8
Run it yourself

Implement Groq reference architecture with model routing, streaming pipelines, and fallbacks. Use when designing new Groq integrations, reviewing project structure, or establishing architecture standards for Groq applications. Trigger with phrases like "groq architecture", "groq best practices", "groq project structure", "how to organize groq", "groq design".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/groq-reference-architecture

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesexamples.md

≈534 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Groq Reference Architecture — Worked Examples

These examples compose the building blocks defined in implementation.md — selectModel, completionWithMiddleware, completionWithFallback, and streamCompletion — into the request shapes an application layer actually issues.

Example 1: Latency-critical chat turn

Route to the speed tier and return a single completion.

import Groq from "groq-sdk";
import { selectModel } from "./groq/router";
import { completionWithMiddleware } from "./groq/middleware";

const groq = new Groq({ apiKey: process.env.GROQ_API_KEY });

const model = selectModel({ maxLatencyMs: 80, costSensitive: true });
// → llama-3.1-8b-instant

const res = await completionWithMiddleware(groq, model.id, [
  { role: "user", content: "Summarize this ticket in one line." },
]);
console.log(res.choices[0].message.content);

Example 2: Quality request with fallback protection

Let the router pick the quality tier, but wrap the call so a 429/5xx drops to a model in a different rate-limit pool before degrading gracefully.

import { selectModel } from "./groq/router";
import { completionWithFallback } from "./groq/fallback";

const model = selectModel({ needsTools: true });   // → llama-3.3-70b-versatile

const res = await completionWithFallback(groq, [
  { role: "user", content: "Extract the invoice total and due date." },
], { primaryModel: model.id });

Example 3: Streaming a chat UI

Consume the async generator token-by-token for a real-time SSE surface.

import { streamCompletion } from "./groq/streaming";

for await (const event of streamCompletion(groq, [
  { role: "user", content: "Explain LPU inference in two sentences." },
])) {
  if (event.type === "token") process.stdout.write(event.content!);
  else if (event.type === "error") console.error(event.error);
}

Example 4: Vision request routing

A request that carries an image auto-routes to the vision-capable model.

const model = selectModel({ needsVision: true });
// → meta-llama/llama-4-scout-17b-16e-instruct

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides a reference architecture and implementation templates for integrating Groq's LPU inference API. It follows best practices by using environment variables for API keys and provides standard patterns for model routing, caching, and error handling. No malicious patterns or security vulnerabilities were detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
What it can do
Reads files
version
1.11.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "groq",
  "groq-reference"
]
All 2 allowed tools
ReadGrep
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/groq-reference-architecture