@warlock.js/ai-groq 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +123 -0
- package/cjs/index.cjs +281 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/config.type.d.mts +122 -0
- package/esm/config.type.d.mts.map +1 -0
- package/esm/index.d.mts +4 -0
- package/esm/index.mjs +4 -0
- package/esm/known-models.d.mts +62 -0
- package/esm/known-models.d.mts.map +1 -0
- package/esm/known-models.mjs +124 -0
- package/esm/known-models.mjs.map +1 -0
- package/esm/sdk.d.mts +100 -0
- package/esm/sdk.d.mts.map +1 -0
- package/esm/sdk.mjs +154 -0
- package/esm/sdk.mjs.map +1 -0
- package/llms-full.txt +122 -0
- package/llms.txt +9 -0
- package/package.json +40 -0
- package/skills/setup-groq/SKILL.md +112 -0
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@warlock.js/ai-groq",
|
|
3
|
+
"description": "Groq adapter for @warlock.js/ai (OpenAI-compatible, thin wrapper over @warlock.js/ai-openai)",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"warlock",
|
|
6
|
+
"ai",
|
|
7
|
+
"groq",
|
|
8
|
+
"llama",
|
|
9
|
+
"openai-compatible"
|
|
10
|
+
],
|
|
11
|
+
"author": "Hasan Zohdy",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/warlockjs/ai-groq"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@warlock.js/ai-openai": "4.6.0",
|
|
19
|
+
"@warlock.js/logger": "4.6.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@warlock.js/ai": "4.6.0"
|
|
23
|
+
},
|
|
24
|
+
"version": "4.6.0",
|
|
25
|
+
"main": "./cjs/index.cjs",
|
|
26
|
+
"module": "./esm/index.mjs",
|
|
27
|
+
"types": "./esm/index.d.mts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./esm/index.d.mts",
|
|
32
|
+
"default": "./esm/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./esm/index.d.mts",
|
|
36
|
+
"default": "./cjs/index.cjs"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-groq
|
|
3
|
+
description: 'Wire @warlock.js/ai-groq — new GroqSDK({apiKey, baseURL?, provider?, pricing?}) for Groq-hosted open models on LPU hardware (llama-3.3-70b-versatile, llama-3.1-8b-instant, openai/gpt-oss-120b/20b, deepseek-r1-distill-llama-70b). Thin wrapper over @warlock.js/ai-openai — uses the OpenAI-compatible endpoint https://api.groq.com/openai/v1, delegating transport/streaming/structured-output/errors to OpenAISDK while injecting Groqs OWN vision/reasoning inference + default pricing. .model({name, vision?, reasoning?, structuredOutput?}) for ModelContract. Triggers: `GroqSDK`, `groq.model`, `groq.count`, `llama-3.3-70b-versatile`, `llama-3.1-8b-instant`, `gpt-oss`, `deepseek-r1-distill`, `groq vision`, `groq reasoning`, `reasoning_effort`, `https://api.groq.com/openai/v1`, OpenAI-compatible Groq, LPU, fast inference; "wire groq into a warlock agent", "use llama 3.3 on groq", "run gpt-oss / deepseek reasoning on groq", "point warlock at the groq endpoint"; import `import { GroqSDK } from "@warlock.js/ai-groq"`. Skip: agent wiring — `@warlock.js/ai/run-ai-agent/SKILL.md`; adapter comparison — `@warlock.js/ai/pick-ai-provider/SKILL.md`; the wrapped adapter `@warlock.js/ai-openai` (`setup-openai`); embeddings (Groq has none — use openai/google); siblings `@warlock.js/ai-anthropic`, `@warlock.js/ai-bedrock`, `@warlock.js/ai-google`, `@warlock.js/ai-ollama`; raw `groq-sdk` / `openai` SDK.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `@warlock.js/ai-groq`
|
|
7
|
+
|
|
8
|
+
Provider adapter for **Groq** — open models (Llama, GPT-OSS, DeepSeek-R1 distill) served fast on Groq's LPU hardware. Groq speaks the OpenAI Chat Completions protocol, so this package is a **thin wrapper over `@warlock.js/ai-openai`**: it owns an internal `OpenAISDK` pointed at Groq's endpoint and delegates the wire work, while injecting Groq's own capability inference and default pricing. Pair with `@warlock.js/ai` for the agent / tool / system-prompt surface.
|
|
9
|
+
|
|
10
|
+
## Construction
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { GroqSDK } from "@warlock.js/ai-groq";
|
|
14
|
+
|
|
15
|
+
// Common path — apiKey only. baseURL + provider default to Groq.
|
|
16
|
+
const groq = new GroqSDK({ apiKey: process.env.GROQ_API_KEY! });
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`baseURL` defaults to `https://api.groq.com/openai/v1` (Groq's **OpenAI-compatible endpoint**) — override only to route through a proxy/gateway. `provider` defaults to `"groq"` and flows through to `ModelContract.provider`, `AgentReport.model.provider`, and logs.
|
|
20
|
+
|
|
21
|
+
`GroqSDK` is a class (not a factory) — it holds a long-lived internal `OpenAISDK` and aligns with the other adapter entry points. Every upstream `openai` `ClientOptions` field (`timeout`, `maxRetries`, `defaultHeaders`, `fetch`, …) is forwarded verbatim to that inner client.
|
|
22
|
+
|
|
23
|
+
## Producing a model
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
groq.model({ name: "llama-3.3-70b-versatile" }) // flagship general-purpose text
|
|
27
|
+
groq.model({ name: "llama-3.1-8b-instant" }) // fastest / cheapest small text
|
|
28
|
+
groq.model({ name: "openai/gpt-oss-120b" }) // vision + reasoning auto-true
|
|
29
|
+
groq.model({ name: "deepseek-r1-distill-llama-70b" }) // reasoning auto-true
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Returns a `ModelContract` you pass straight into `ai.agent({ model })`. `name` is the Groq-hosted **open-weight** id (the upstream name, e.g. `openai/gpt-oss-120b`), NOT an OpenAI id. Any current Groq model id works — the list above is curated, not an allow-list.
|
|
33
|
+
|
|
34
|
+
## Capabilities — what's auto-set
|
|
35
|
+
|
|
36
|
+
The whole reason this wrapper exists: Groq's ids aren't OpenAI's, so the OpenAI adapter's prefix inference would never fire. `GroqSDK` carries its **own** name lists.
|
|
37
|
+
|
|
38
|
+
| Flag | Default |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `vision` | Inferred from the Groq model id. `true` for `gpt-oss`, `llama-4`, `llama-3.2-*-vision`; `false` otherwise (e.g. `llama-3.3-70b-versatile`, `llama-3.1-8b-instant`). |
|
|
41
|
+
| `reasoning` | Inferred from the Groq model id. `true` for `gpt-oss`, `deepseek-r1` / `deepseek-r1-distill`, `qwq`, `qwen3`; `false` otherwise. Drives whether `reasoning_effort` is forwarded. |
|
|
42
|
+
| `structuredOutput` | `true` — Groq accepts OpenAI-style `response_format`. |
|
|
43
|
+
| `promptCaching` | Inherited from the inner OpenAI adapter (`true`; read-side `cachedTokens` accounting). |
|
|
44
|
+
|
|
45
|
+
**Override `vision`, `reasoning`, or `structuredOutput` explicitly** via `.model({ name, vision?, reasoning?, structuredOutput? })` — an explicit value always wins over inference.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
groq.model({ name: "some-custom-llama", vision: true }) // force on for an unlisted multimodal id
|
|
49
|
+
groq.model({ name: "openai/gpt-oss-120b", reasoning: false }) // pin off
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Reasoning (gpt-oss / deepseek-r1 distill)
|
|
53
|
+
|
|
54
|
+
Reasoning models accept a discrete effort knob, forwarded by the inner adapter as OpenAI's `reasoning_effort`:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const model = groq.model({ name: "deepseek-r1-distill-llama-70b" }); // reasoning auto-true
|
|
58
|
+
await model.complete(messages, { reasoning: { effort: "high" } }); // → reasoning_effort: "high"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `reasoning.effort` (`"low" | "medium" | "high"`) maps verbatim.
|
|
62
|
+
- `reasoning.maxTokens` has no Chat Completions equivalent and is ignored (same as the OpenAI adapter).
|
|
63
|
+
- When `capabilities.reasoning` is `false` (e.g. `llama-3.3-70b-versatile`), the option is dropped — never sent as an unsupported param.
|
|
64
|
+
|
|
65
|
+
## Structured output & streaming
|
|
66
|
+
|
|
67
|
+
Inherited unchanged from `@warlock.js/ai-openai`: a `responseSchema` maps to `response_format: json_schema` (strict) when the schema is a proper root object, else loose `json_object`; `model.stream()` drains the streaming Chat Completions response and yields `delta` / `tool-call` / `done` chunks with `include_usage` on. See [`setup-openai`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) for the full wire behavior.
|
|
68
|
+
|
|
69
|
+
## Embeddings — not available on Groq
|
|
70
|
+
|
|
71
|
+
As of mid-2026 Groq exposes **no** OpenAI-compatible embeddings endpoint. `groq.embedder({ name })` constructs (delegated to the inner adapter) but a live `.embed()` call fails at the provider. Use `@warlock.js/ai-openai` or `@warlock.js/ai-google` for retrieval embeddings.
|
|
72
|
+
|
|
73
|
+
There is also no image-generation API on Groq, so `GroqSDK` intentionally does **not** define `image()` — `ai.groq.image(...)` is a compile-time error (structural capability guard, like Anthropic / Bedrock / Ollama).
|
|
74
|
+
|
|
75
|
+
## Pricing — per-model registry + built-in defaults
|
|
76
|
+
|
|
77
|
+
`pricing` is a registry keyed by model name, rates in **USD per 1,000,000 tokens** (`ModelPricing`: `input`, `output`, optional `cachedInput` / `cachedOutput`). The adapter ships **built-in default rates** for the known Groq models as the final fallback.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const groq = new GroqSDK({
|
|
81
|
+
apiKey,
|
|
82
|
+
pricing: {
|
|
83
|
+
"llama-3.3-70b-versatile": { input: 0.59, output: 0.79 }, // USD per 1M tokens
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Resolution at `model()` time: per-model `pricing` (`groq.model({ name, pricing })`) > SDK `pricing[name]` > adapter built-in default for the id > `undefined` (no cost computed). Built-in defaults exist for `llama-3.3-70b-versatile`, `llama-3.1-8b-instant`, `openai/gpt-oss-120b`, `openai/gpt-oss-20b`, and `deepseek-r1-distill-llama-70b`; supply your own for anything else.
|
|
89
|
+
|
|
90
|
+
## Token counting
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
await groq.count("some text") // approximate heuristic (delegated), not a real tokenizer
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Good for budgeting; not for billing.
|
|
97
|
+
|
|
98
|
+
## Errors
|
|
99
|
+
|
|
100
|
+
Raw errors are wrapped into the typed `@warlock.js/ai` `AIError` hierarchy by the inner OpenAI adapter's error wrapper (dispatch keys on `status + code`). See [`@warlock.js/ai/handle-ai-errors/SKILL.md`](@warlock.js/ai/handle-ai-errors/SKILL.md). Note Groq's documented OpenAI-compat gaps — `n` must be `1`, and `logprobs` / `logit_bias` / `top_logprobs` / `messages[].name` are unsupported.
|
|
101
|
+
|
|
102
|
+
## When NOT to use this skill
|
|
103
|
+
|
|
104
|
+
- Embeddings or image generation — Groq has neither; use `@warlock.js/ai-openai` / `@warlock.js/ai-google`.
|
|
105
|
+
- OpenAI / Azure / OpenRouter — use `@warlock.js/ai-openai` (`setup-openai`); this wraps it but for Groq specifically.
|
|
106
|
+
- Anthropic — `@warlock.js/ai-anthropic`. Bedrock — `@warlock.js/ai-bedrock`. Gemini — `@warlock.js/ai-google`. Local Ollama — `@warlock.js/ai-ollama`.
|
|
107
|
+
|
|
108
|
+
## See also
|
|
109
|
+
|
|
110
|
+
- [`@warlock.js/ai-openai/skills/setup-openai/SKILL.md`](@warlock.js/ai-openai/skills/setup-openai/SKILL.md) — the wrapped adapter; full wire / streaming / structured-output detail
|
|
111
|
+
- [`@warlock.js/ai/run-ai-agent/SKILL.md`](@warlock.js/ai/run-ai-agent/SKILL.md) — passing the model into `ai.agent({...})`
|
|
112
|
+
- [`@warlock.js/ai/pick-ai-provider/SKILL.md`](@warlock.js/ai/pick-ai-provider/SKILL.md) — adapter comparison
|