AGENT SKILL

groq-inference

Ultra-fast LLM inference on custom LPU hardware. OpenAI-compatible API at api.groq.com. Lowest latency in the industry (500-1000+ tok/s). Supports chat completions, vision, audio (Whisper STT + TTS), tool calling, JSON mode, and streaming. Free tier available. Inference only — no training.

使用场景图像与多媒体
License 许可
MIT
所属仓库
fadrienne/MyGitHub
最近更新
2026-10-28
Stars
★ 0
Forks
0

01 前言 Front Matter

name
groq-inference
tags
[ "Inference", "Groq", "LPU", "Low-Latency", "OpenAI-Compatible", "Free-Tier" ]
author
Synthetic Sciences
license
MIT
version
1.0.0
category
ml-inference
description
Ultra-fast LLM inference on custom LPU hardware. OpenAI-compatible API at api.groq.com. Lowest latency in the industry (500-1000+ tok/s). Supports chat completions, vision, audio (Whisper STT + TTS), tool calling, JSON mode, and streaming. Free tier available. Inference only — no training.
dependencies
[ "groq", "openai" ]

03 SKILL.md 正文

Groq — Ultra-Fast LLM Inference

Groq runs open-weight LLMs on custom LPU (Language Processing Unit) hardware, delivering the lowest inference latency in the industry — up to 1000+ tokens/sec. OpenAI-compatible API, free tier, pay-per-token pricing. Inference only, no training.

When to Use Groq

Use when:

  • You need the fastest possible inference latency (real-time chat, agents, interactive apps)
  • You want open-weight models (Llama, Qwen, DeepSeek) without managing GPUs
  • You need an OpenAI-compatible drop-in replacement with open models
  • You want free-tier access for prototyping
  • You need fast Whisper transcription or vision with Llama 4

Don't use when:

  • You need to fine-tune or train models (inference-only)
  • You need proprietary models (GPT-4o, Claude, Gemini)
  • You need embeddings or image generation APIs (not offered)
Feature Groq Together AI Fireworks Replicate
Hardware Custom LPU NVIDIA GPUs NVIDIA GPUs NVIDIA GPUs
Speed (Llama 70B) ~280 tok/s ~100 tok/s ~100 tok/s ~50 tok/s
Free tier Yes Yes Yes No
Training No Yes Yes Yes

Credential Setup

Credentials are auto-injected by openscience when connected via the dashboard.

# Verify credentials
[ -n "$GROQ_API_KEY" ] && echo "GROQ_API_KEY set" || echo "NOT SET"

If not set: connect Groq at https://app.syntheticsciences.ai -> Services, then restart openscience.

Quick Start

pip install groq
export GROQ_API_KEY="gsk_..."   # https://console.groq.com/keys
from groq import Groq

client = Groq()
response = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in one paragraph."}
    ],
    temperature=0.7,
    max_completion_tokens=512,
)
print(response.choices[0].message.content)

Chat Completions

Streaming

from groq import Groq

client = Groq()
stream = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{"role": "user", "content": "Explain fast inference"}],
    stream=True,
)
for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="")

JSON Mode

from groq import Groq
import json

client = Groq()
response = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[
        {"role": "system", "content": "Output valid JSON only."},
        {"role": "user", "content": "List 3 programming languages with their paradigms."}
    ],
    response_format={"type": "json_object"},
    temperature=0,
)
data = json.loads(response.choices[0].message.content)

Tool / Function Calling

from groq import Groq
import json

client = Groq()
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get weather for a location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string", "description": "City name"},
                "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["location"],
            "additionalProperties": False
        }
    }
}]

response = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{"role": "user", "content": "Weather in San Francisco?"}],
    tools=tools,
    tool_choice="auto",
)

message = response.choices[0].message
if message.tool_calls:
    call = message.tool_calls[0]
    args = json.loads(call.function.arguments)
    # Execute function, then send result back as role="tool" message
    result = {"temperature": 62, "condition": "foggy"}
    followup = client.chat.completions.create(
        model="llama-3.3-70b-versatile",
        messages=[
            {"role": "user", "content": "Weather in San Francisco?"},
            message,
            {"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)}
        ],
    )
    print(followup.choices[0].message.content)

Vision

Llama 4 models support image input via URL or base64. Max image size: 20 MB.

from groq import Groq

client = Groq()
response = client.chat.completions.create(
    model="meta-llama/llama-4-scout-17b-16e-instruct",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this image."},
            {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
        ]
    }],
    max_completion_tokens=1024,
)
print(response.choices[0].message.content)

Vision models: meta-llama/llama-4-scout-17b-16e-instruct, meta-llama/llama-4-maverick-17b-128e-instruct.

Audio / Speech-to-Text

Whisper on LPU for near-instant transcription. Formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. Max: 25 MB free / 100 MB developer tier.

from groq import Groq

client = Groq()

# Transcription
with open("audio.mp3", "rb") as f:
    result = client.audio.transcriptions.create(
        file=("audio.mp3", f),
        model="whisper-large-v3-turbo",
        language="en",
        response_format="verbose_json",
    )
print(result.text)

# Translation (any language -> English)
with open("french.mp3", "rb") as f:
    result = client.audio.translations.create(
        file=("french.mp3", f), model="whisper-large-v3",
    )
print(result.text)

Text-to-Speech

from groq import Groq
from pathlib import Path

client = Groq()
speech = client.audio.speech.create(
    model="playai-tts",
    voice="Arista-PlayAI",
    input="Hello from Groq!",
)
Path("output.mp3").write_bytes(speech.content)

Model Selection

Production Models

Model Model ID Speed Context Max Output Input $/1M Output $/1M
Llama 3.1 8B llama-3.1-8b-instant 560 t/s 131,072 131,072 $0.05 $0.08
Llama 3.3 70B llama-3.3-70b-versatile 280 t/s 131,072 32,768 $0.59 $0.79
GPT-OSS 120B openai/gpt-oss-120b 500 t/s 131,072 65,536 $0.15 $0.60
GPT-OSS 20B openai/gpt-oss-20b 1000 t/s 131,072 65,536 $0.075 $0.30
Whisper V3 whisper-large-v3 - - - $0.111/hr -
Whisper V3 Turbo whisper-large-v3-turbo - - - $0.04/hr -

Preview Models

Model Model ID Speed Context Input $/1M Output $/1M
Llama 4 Scout meta-llama/llama-4-scout-17b-16e-instruct 750 t/s 131,072 $0.11 $0.34
Llama 4 Maverick meta-llama/llama-4-maverick-17b-128e-instruct 600 t/s 131,072 $0.20 $0.60
Qwen3 32B qwen/qwen3-32b 400 t/s 131,072 $0.29 $0.59
Kimi K2 moonshotai/kimi-k2-instruct-0905 200 t/s 262,144 $1.00 $3.00
Safety GPT-OSS 20B openai/gpt-oss-safeguard-20b 1000 t/s 131,072 $0.075 $0.30
Llama Guard 4 12B meta-llama/llama-guard-4-12b - 131,072 $0.20 $0.20

Systems & TTS

Model Model ID Notes
Compound groq/compound Agentic: web search + code exec
Compound Mini groq/compound-mini Lighter agentic system
PlayAI TTS playai-tts $22/1M chars
Orpheus English canopylabs/orpheus-v1-english $22/1M chars

Selection Guide

  • Fastest + cheapest: llama-3.1-8b-instant — classification, extraction, simple tasks
  • Best quality: llama-3.3-70b-versatile — complex reasoning, coding, chat
  • Best value: openai/gpt-oss-120b — strong quality, 500 t/s, $0.15 input
  • Vision: meta-llama/llama-4-scout-17b-16e-instruct — 750 t/s, cheapest multimodal
  • Long context: moonshotai/kimi-k2-instruct-0905 — 262K context window
  • Safety: meta-llama/llama-guard-4-12b or openai/gpt-oss-safeguard-20b

OpenAI Compatibility

Drop-in replacement — change base_url and api_key:

from openai import OpenAI
import os

client = OpenAI(
    base_url="https://api.groq.com/openai/v1",
    api_key=os.environ.get("GROQ_API_KEY"),
)
response = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{"role": "user", "content": "Hello from OpenAI SDK!"}],
)
print(response.choices[0].message.content)
Endpoint Supported Notes
POST /chat/completions Yes Streaming, tools, JSON mode
POST /audio/transcriptions Yes Whisper
POST /audio/translations Yes Whisper
POST /audio/speech Yes TTS
GET /models Yes List models
POST /embeddings No Not available
POST /images/generations No Not available

Unsupported fields (400 error): logprobs, logit_bias, top_logprobs, messages[].name, n (must be 1).

Rate Limits

Tier Price RPM TPM TPD
Free $0 30 6,000 500,000
Developer Pay-per-token Up to 1,000 Up to 300,000 Unlimited

Rate limit headers returned with every response: x-ratelimit-limit-requests, x-ratelimit-remaining-requests, x-ratelimit-limit-tokens, x-ratelimit-remaining-tokens.

import time
from groq import Groq, RateLimitError

client = Groq()

def call_with_retry(messages, model="llama-3.3-70b-versatile", max_retries=3):
    for attempt in range(max_retries):
        try:
            return client.chat.completions.create(model=model, messages=messages)
        except RateLimitError:
            if attempt == max_retries - 1:
                raise
            time.sleep(2 ** attempt)

Cost Optimization

  1. Use the smallest model that works. llama-3.1-8b-instant is 10x cheaper than the 70B for simple tasks.
  2. Cap output with max_completion_tokens. Output tokens cost more than input.
  3. Try openai/gpt-oss-20b — best price/performance at $0.075 input and 1000 t/s.
  4. Cache at temperature=0. Deterministic output means identical prompts yield identical results.
  5. Use Whisper Turbo. whisper-large-v3-turbo is 64% cheaper than v3 with minimal quality loss.
  6. Preprocess audio to 16KHz mono WAV to reduce upload size.

Common Issues

Problem Solution
401 Unauthorized Check GROQ_API_KEY. Get key at https://console.groq.com/keys
400 Bad Request Remove unsupported fields: logprobs, logit_bias, top_logprobs
429 Rate Limited Exponential backoff. Upgrade to developer tier for 10x limits
Empty stream chunks Check chunk.choices[0].delta.content for None
Invalid JSON output Add "Output valid JSON only" to system prompt, set temperature=0
Tool calls missing Not all models support tools. Use Llama 3.3 70B or GPT-OSS
Audio too large Free: 25 MB max. Use url param or upgrade to dev tier (100 MB)
Vision fails Only Llama 4 models support vision. Max 20 MB
n param error Groq only supports n=1
max_tokens warning Use max_completion_tokens instead

Resources

04 同仓库更多 Skills

fadrienne
fadrienne/MyGitHub

statistical-power

Sample size calculation, power analysis, and effect size conversion for scientific studies. Use BEFORE data collection (a priori) to determine required N, or after (post-hoc) to compute achieved power. Covers parametric tests (t-test, ANOVA, chi-square, proportions, correlation, regression), simulation-based power for complex/clustered/nested designs, and power curves. Use this skill when someone asks 'how many samples do I need', 'what is my power', 'what effect size can I detect', or any variant. Pairs with /experimental-design (choose design first, then compute power) and /statistical-analysis (analyze data after collection).

Skill与智能体开发
★ 0
fadrienne
fadrienne/MyGitHub

statistical-analysis

Guided statistical analysis with test selection and reporting. Use when you need help choosing appropriate tests for your data, assumption checking, power analysis, and APA-formatted results. Best for academic research reporting, test selection guidance. For implementing specific models programmatically use statsmodels.

测试与质量
★ 0
fadrienne
fadrienne/MyGitHub

scientific-writing

Core skill for the deep research and writing tool. Write scientific manuscripts in full paragraphs (never bullet points). Use two-stage process with (1) section outlines with key points using research-lookup then (2) convert to flowing prose. IMRAD structure, citations (APA/AMA/Vancouver), figures/tables, reporting guidelines (CONSORT/STROBE/PRISMA), for research papers and journal submissions.

内容创作者写作与文案Skill与智能体开发
★ 0
fadrienne
fadrienne/MyGitHub

scientific-visualization

Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib/seaborn/plotly with publication styles. For quick exploration use seaborn or plotly directly.

分析与可视化Skill与智能体开发
★ 0
fadrienne
fadrienne/MyGitHub

research-code

Debug, profile, review, and restructure Python research and analysis code. Use when analysis scripts crash, produce wrong results, run too slowly, or need a correctness review. Covers: reading tracebacks and diagnosing root causes, hypothesis-driven debugging, reviewing code for common statistical/numerical errors, profiling data pipelines, improving reproducibility (seeds, environments, determinism), and structuring analysis scripts for sharing. Distinct from /exploratory-data-analysis (which understands data) and /statistical-analysis (which chooses and runs tests) — this skill focuses on the code itself.

开发工程师资料检索与研究
★ 0
fadrienne
fadrienne/MyGitHub

markdown-mermaid-writing

Comprehensive markdown and Mermaid diagram writing skill. Use when creating any scientific document, report, analysis, or visualization. Establishes text-based diagrams as the default documentation standard with full style guides (markdown + mermaid), 24 diagram type references, and 9 document templates.

内容创作者文档处理写作与文案
★ 0