@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.
@@ -0,0 +1,62 @@
1
+ //#region ../@warlock.js/ai-groq/src/known-models.d.ts
2
+ /**
3
+ * Default base URL for Groq's OpenAI-compatible Chat Completions
4
+ * endpoint. Groq exposes the same wire protocol as OpenAI under this
5
+ * prefix, which is exactly why `GroqSDK` can delegate to the
6
+ * battle-tested `OpenAISDK` instead of reimplementing the transport.
7
+ *
8
+ * Verified against Groq's "OpenAI Compatibility" docs (mid-2026).
9
+ * Override via `new GroqSDK({ baseURL })` if Groq ever relocates it.
10
+ */
11
+ declare const GROQ_BASE_URL = "https://api.groq.com/openai/v1";
12
+ /**
13
+ * The provider label every model produced by `GroqSDK` self-identifies
14
+ * with. Flows through to `ModelContract.provider`, `AgentReport.model`,
15
+ * logs, and any provider-aware middleware. Kept as a constant so the
16
+ * wrapper and the inner `OpenAISDK` agree on one spelling.
17
+ */
18
+ declare const GROQ_PROVIDER = "groq";
19
+ /**
20
+ * Infer whether a Groq-hosted model id supports vision based on the
21
+ * known multimodal-family substrings. Unknown ids default to `false`
22
+ * so passing an image attachment to a text-only model (e.g.
23
+ * `llama-3.3-70b-versatile`) surfaces a clear, agent-side capability
24
+ * error instead of an opaque upstream 400.
25
+ *
26
+ * @example
27
+ * inferVisionCapability("openai/gpt-oss-120b"); // → true
28
+ * inferVisionCapability("meta-llama/llama-4-scout"); // → true
29
+ * inferVisionCapability("llama-3.3-70b-versatile"); // → false
30
+ * inferVisionCapability("llama-3.1-8b-instant"); // → false
31
+ */
32
+ declare function inferVisionCapability(modelId: string): boolean;
33
+ /**
34
+ * Infer whether a Groq-hosted model id is a reasoning model based on
35
+ * the known reasoning-family substrings. Unknown ids default to `false`
36
+ * so the adapter never forwards an unsupported `reasoning_effort` param
37
+ * to a non-reasoning model (which would 400).
38
+ *
39
+ * @example
40
+ * inferReasoningCapability("openai/gpt-oss-20b"); // → true
41
+ * inferReasoningCapability("deepseek-r1-distill-llama-70b"); // → true
42
+ * inferReasoningCapability("llama-3.3-70b-versatile"); // → false
43
+ */
44
+ declare function inferReasoningCapability(modelId: string): boolean;
45
+ /**
46
+ * Curated list of current Groq production chat model ids (mid-2026),
47
+ * for autocomplete, docs, and default selection. NOT exhaustive and NOT
48
+ * a runtime allow-list — `groq.model({ name })` accepts any string, so
49
+ * a newly launched id works the moment Groq ships it without a package
50
+ * bump. Deprecated ids (e.g. several `llama-4` variants retired in 2026)
51
+ * are intentionally excluded.
52
+ *
53
+ * - `llama-3.3-70b-versatile` — flagship general-purpose text model.
54
+ * - `llama-3.1-8b-instant` — fastest/cheapest small text model.
55
+ * - `openai/gpt-oss-120b` / `openai/gpt-oss-20b` — OpenAI open-weight
56
+ * family; vision + reasoning capable.
57
+ * - `deepseek-r1-distill-llama-70b` — DeepSeek-R1-style reasoning.
58
+ */
59
+ declare const GROQ_KNOWN_MODELS: readonly ["llama-3.3-70b-versatile", "llama-3.1-8b-instant", "openai/gpt-oss-120b", "openai/gpt-oss-20b", "deepseek-r1-distill-llama-70b"];
60
+ //#endregion
61
+ export { GROQ_BASE_URL, GROQ_KNOWN_MODELS, GROQ_PROVIDER, inferReasoningCapability, inferVisionCapability };
62
+ //# sourceMappingURL=known-models.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"known-models.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/known-models.ts"],"mappings":";;AASA;;;;AAA0B;AAQ1B;;;cARa,aAAA;AAQa;AAkE1B;;;;AAAqD;AAlE3B,cAAb,aAAA;;;;AAmF2C;AAoBxD;;;;AAMU;;;;;iBA3CM,qBAAA,CAAsB,OAAe;;;;;;;;;;;;iBAiBrC,wBAAA,CAAyB,OAAe;;;;;;;;;;;;;;;cAoB3C,iBAAA"}
@@ -0,0 +1,124 @@
1
+ //#region ../@warlock.js/ai-groq/src/known-models.ts
2
+ /**
3
+ * Default base URL for Groq's OpenAI-compatible Chat Completions
4
+ * endpoint. Groq exposes the same wire protocol as OpenAI under this
5
+ * prefix, which is exactly why `GroqSDK` can delegate to the
6
+ * battle-tested `OpenAISDK` instead of reimplementing the transport.
7
+ *
8
+ * Verified against Groq's "OpenAI Compatibility" docs (mid-2026).
9
+ * Override via `new GroqSDK({ baseURL })` if Groq ever relocates it.
10
+ */
11
+ const GROQ_BASE_URL = "https://api.groq.com/openai/v1";
12
+ /**
13
+ * The provider label every model produced by `GroqSDK` self-identifies
14
+ * with. Flows through to `ModelContract.provider`, `AgentReport.model`,
15
+ * logs, and any provider-aware middleware. Kept as a constant so the
16
+ * wrapper and the inner `OpenAISDK` agree on one spelling.
17
+ */
18
+ const GROQ_PROVIDER = "groq";
19
+ /**
20
+ * Substrings identifying Groq-hosted model ids whose family accepts
21
+ * image input (vision).
22
+ *
23
+ * Groq hosts *open* models on its LPU hardware, so the ids are the
24
+ * upstream open-weight names rather than OpenAI's — which is why the
25
+ * OpenAI adapter's `gpt-4o*` prefix inference would never fire here and
26
+ * this provider must carry its OWN list. Verified against Groq's
27
+ * supported-models catalog (mid-2026):
28
+ *
29
+ * - `openai/gpt-oss-*` — natively multimodal OpenAI open-weight family
30
+ * (the current production vision + reasoning models on Groq).
31
+ * - `llama-4` / `llama-3.2-*-vision` — Meta's multimodal Llama families.
32
+ * Kept as substrings so any still-hosted or re-introduced variant is
33
+ * covered even though some `llama-4` ids were deprecated in 2026.
34
+ *
35
+ * Matched as a substring (not a prefix) because Groq prefixes several
36
+ * ids with an org segment (`openai/`, `meta-llama/`) and appends size /
37
+ * date suffixes. Override per-model via
38
+ * `groq.model({ name, vision: true | false })`.
39
+ */
40
+ const VISION_CAPABLE_SUBSTRINGS = [
41
+ "gpt-oss",
42
+ "llama-4",
43
+ "llama-3.2-11b-vision",
44
+ "llama-3.2-90b-vision",
45
+ "vision"
46
+ ];
47
+ /**
48
+ * Substrings identifying Groq-hosted model ids that expose an internal
49
+ * reasoning / thinking channel and accept the `reasoning_effort`
50
+ * request parameter on the OpenAI-compatible Chat Completions endpoint.
51
+ *
52
+ * Verified against Groq's catalog (mid-2026):
53
+ * - `gpt-oss` — the OpenAI open-weight family reasons by default.
54
+ * - `deepseek-r1-distill` — DeepSeek-R1-style reasoning at Groq speed.
55
+ * - `qwq` / `qwen3` — Qwen reasoning families (when hosted).
56
+ *
57
+ * Matched as a substring for the same org-prefix / suffix reason as the
58
+ * vision list. Override per-model via
59
+ * `groq.model({ name, reasoning: true | false })`.
60
+ */
61
+ const REASONING_CAPABLE_SUBSTRINGS = [
62
+ "gpt-oss",
63
+ "deepseek-r1",
64
+ "deepseek-r1-distill",
65
+ "qwq",
66
+ "qwen3"
67
+ ];
68
+ /**
69
+ * Infer whether a Groq-hosted model id supports vision based on the
70
+ * known multimodal-family substrings. Unknown ids default to `false`
71
+ * so passing an image attachment to a text-only model (e.g.
72
+ * `llama-3.3-70b-versatile`) surfaces a clear, agent-side capability
73
+ * error instead of an opaque upstream 400.
74
+ *
75
+ * @example
76
+ * inferVisionCapability("openai/gpt-oss-120b"); // → true
77
+ * inferVisionCapability("meta-llama/llama-4-scout"); // → true
78
+ * inferVisionCapability("llama-3.3-70b-versatile"); // → false
79
+ * inferVisionCapability("llama-3.1-8b-instant"); // → false
80
+ */
81
+ function inferVisionCapability(modelId) {
82
+ const normalized = modelId.toLowerCase();
83
+ return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));
84
+ }
85
+ /**
86
+ * Infer whether a Groq-hosted model id is a reasoning model based on
87
+ * the known reasoning-family substrings. Unknown ids default to `false`
88
+ * so the adapter never forwards an unsupported `reasoning_effort` param
89
+ * to a non-reasoning model (which would 400).
90
+ *
91
+ * @example
92
+ * inferReasoningCapability("openai/gpt-oss-20b"); // → true
93
+ * inferReasoningCapability("deepseek-r1-distill-llama-70b"); // → true
94
+ * inferReasoningCapability("llama-3.3-70b-versatile"); // → false
95
+ */
96
+ function inferReasoningCapability(modelId) {
97
+ const normalized = modelId.toLowerCase();
98
+ return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));
99
+ }
100
+ /**
101
+ * Curated list of current Groq production chat model ids (mid-2026),
102
+ * for autocomplete, docs, and default selection. NOT exhaustive and NOT
103
+ * a runtime allow-list — `groq.model({ name })` accepts any string, so
104
+ * a newly launched id works the moment Groq ships it without a package
105
+ * bump. Deprecated ids (e.g. several `llama-4` variants retired in 2026)
106
+ * are intentionally excluded.
107
+ *
108
+ * - `llama-3.3-70b-versatile` — flagship general-purpose text model.
109
+ * - `llama-3.1-8b-instant` — fastest/cheapest small text model.
110
+ * - `openai/gpt-oss-120b` / `openai/gpt-oss-20b` — OpenAI open-weight
111
+ * family; vision + reasoning capable.
112
+ * - `deepseek-r1-distill-llama-70b` — DeepSeek-R1-style reasoning.
113
+ */
114
+ const GROQ_KNOWN_MODELS = [
115
+ "llama-3.3-70b-versatile",
116
+ "llama-3.1-8b-instant",
117
+ "openai/gpt-oss-120b",
118
+ "openai/gpt-oss-20b",
119
+ "deepseek-r1-distill-llama-70b"
120
+ ];
121
+
122
+ //#endregion
123
+ export { GROQ_BASE_URL, GROQ_KNOWN_MODELS, GROQ_PROVIDER, inferReasoningCapability, inferVisionCapability };
124
+ //# sourceMappingURL=known-models.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"known-models.mjs","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/known-models.ts"],"sourcesContent":["/**\n * Default base URL for Groq's OpenAI-compatible Chat Completions\n * endpoint. Groq exposes the same wire protocol as OpenAI under this\n * prefix, which is exactly why `GroqSDK` can delegate to the\n * battle-tested `OpenAISDK` instead of reimplementing the transport.\n *\n * Verified against Groq's \"OpenAI Compatibility\" docs (mid-2026).\n * Override via `new GroqSDK({ baseURL })` if Groq ever relocates it.\n */\nexport const GROQ_BASE_URL = \"https://api.groq.com/openai/v1\";\n\n/**\n * The provider label every model produced by `GroqSDK` self-identifies\n * with. Flows through to `ModelContract.provider`, `AgentReport.model`,\n * logs, and any provider-aware middleware. Kept as a constant so the\n * wrapper and the inner `OpenAISDK` agree on one spelling.\n */\nexport const GROQ_PROVIDER = \"groq\";\n\n/**\n * Substrings identifying Groq-hosted model ids whose family accepts\n * image input (vision).\n *\n * Groq hosts *open* models on its LPU hardware, so the ids are the\n * upstream open-weight names rather than OpenAI's — which is why the\n * OpenAI adapter's `gpt-4o*` prefix inference would never fire here and\n * this provider must carry its OWN list. Verified against Groq's\n * supported-models catalog (mid-2026):\n *\n * - `openai/gpt-oss-*` — natively multimodal OpenAI open-weight family\n * (the current production vision + reasoning models on Groq).\n * - `llama-4` / `llama-3.2-*-vision` — Meta's multimodal Llama families.\n * Kept as substrings so any still-hosted or re-introduced variant is\n * covered even though some `llama-4` ids were deprecated in 2026.\n *\n * Matched as a substring (not a prefix) because Groq prefixes several\n * ids with an org segment (`openai/`, `meta-llama/`) and appends size /\n * date suffixes. Override per-model via\n * `groq.model({ name, vision: true | false })`.\n */\nconst VISION_CAPABLE_SUBSTRINGS = [\n \"gpt-oss\",\n \"llama-4\",\n \"llama-3.2-11b-vision\",\n \"llama-3.2-90b-vision\",\n \"vision\",\n];\n\n/**\n * Substrings identifying Groq-hosted model ids that expose an internal\n * reasoning / thinking channel and accept the `reasoning_effort`\n * request parameter on the OpenAI-compatible Chat Completions endpoint.\n *\n * Verified against Groq's catalog (mid-2026):\n * - `gpt-oss` — the OpenAI open-weight family reasons by default.\n * - `deepseek-r1-distill` — DeepSeek-R1-style reasoning at Groq speed.\n * - `qwq` / `qwen3` — Qwen reasoning families (when hosted).\n *\n * Matched as a substring for the same org-prefix / suffix reason as the\n * vision list. Override per-model via\n * `groq.model({ name, reasoning: true | false })`.\n */\nconst REASONING_CAPABLE_SUBSTRINGS = [\n \"gpt-oss\",\n \"deepseek-r1\",\n \"deepseek-r1-distill\",\n \"qwq\",\n \"qwen3\",\n];\n\n/**\n * Infer whether a Groq-hosted model id supports vision based on the\n * known multimodal-family substrings. Unknown ids default to `false`\n * so passing an image attachment to a text-only model (e.g.\n * `llama-3.3-70b-versatile`) surfaces a clear, agent-side capability\n * error instead of an opaque upstream 400.\n *\n * @example\n * inferVisionCapability(\"openai/gpt-oss-120b\"); // → true\n * inferVisionCapability(\"meta-llama/llama-4-scout\"); // → true\n * inferVisionCapability(\"llama-3.3-70b-versatile\"); // → false\n * inferVisionCapability(\"llama-3.1-8b-instant\"); // → false\n */\nexport function inferVisionCapability(modelId: string): boolean {\n const normalized = modelId.toLowerCase();\n\n return VISION_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Infer whether a Groq-hosted model id is a reasoning model based on\n * the known reasoning-family substrings. Unknown ids default to `false`\n * so the adapter never forwards an unsupported `reasoning_effort` param\n * to a non-reasoning model (which would 400).\n *\n * @example\n * inferReasoningCapability(\"openai/gpt-oss-20b\"); // → true\n * inferReasoningCapability(\"deepseek-r1-distill-llama-70b\"); // → true\n * inferReasoningCapability(\"llama-3.3-70b-versatile\"); // → false\n */\nexport function inferReasoningCapability(modelId: string): boolean {\n const normalized = modelId.toLowerCase();\n\n return REASONING_CAPABLE_SUBSTRINGS.some((fragment) => normalized.includes(fragment));\n}\n\n/**\n * Curated list of current Groq production chat model ids (mid-2026),\n * for autocomplete, docs, and default selection. NOT exhaustive and NOT\n * a runtime allow-list — `groq.model({ name })` accepts any string, so\n * a newly launched id works the moment Groq ships it without a package\n * bump. Deprecated ids (e.g. several `llama-4` variants retired in 2026)\n * are intentionally excluded.\n *\n * - `llama-3.3-70b-versatile` — flagship general-purpose text model.\n * - `llama-3.1-8b-instant` — fastest/cheapest small text model.\n * - `openai/gpt-oss-120b` / `openai/gpt-oss-20b` — OpenAI open-weight\n * family; vision + reasoning capable.\n * - `deepseek-r1-distill-llama-70b` — DeepSeek-R1-style reasoning.\n */\nexport const GROQ_KNOWN_MODELS = [\n \"llama-3.3-70b-versatile\",\n \"llama-3.1-8b-instant\",\n \"openai/gpt-oss-120b\",\n \"openai/gpt-oss-20b\",\n \"deepseek-r1-distill-llama-70b\",\n] as const;\n"],"mappings":";;;;;;;;;;AASA,MAAa,gBAAgB;;;;;;;AAQ7B,MAAa,gBAAgB;;;;;;;;;;;;;;;;;;;;;;AAuB7B,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;;AAgBA,MAAM,+BAA+B;CACnC;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,SAAgB,sBAAsB,SAA0B;CAC9D,MAAM,aAAa,QAAQ,YAAY;CAEvC,OAAO,0BAA0B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACnF;;;;;;;;;;;;AAaA,SAAgB,yBAAyB,SAA0B;CACjE,MAAM,aAAa,QAAQ,YAAY;CAEvC,OAAO,6BAA6B,MAAM,aAAa,WAAW,SAAS,QAAQ,CAAC;AACtF;;;;;;;;;;;;;;;AAgBA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;AACF"}
package/esm/sdk.d.mts ADDED
@@ -0,0 +1,100 @@
1
+ import { GroqEmbedderConfig, GroqModelConfig, GroqSDKConfig } from "./config.type.mjs";
2
+ import { EmbedderContract, ModelContract, SDKAdapterContract } from "@warlock.js/ai";
3
+
4
+ //#region ../@warlock.js/ai-groq/src/sdk.d.ts
5
+ /**
6
+ * Groq-backed implementation of `SDKAdapterContract`.
7
+ *
8
+ * **Role.** The package entry point for Groq-hosted open models
9
+ * (`llama-3.3-70b-versatile`, `llama-3.1-8b-instant`,
10
+ * `openai/gpt-oss-*`, `deepseek-r1-distill-*`, …) served on Groq's fast
11
+ * LPU hardware. Because Groq exposes the OpenAI Chat Completions wire
12
+ * protocol verbatim, `GroqSDK` is a **thin wrapper over the already
13
+ * battle-tested {@link OpenAISDK}** rather than a fresh transport
14
+ * implementation — it owns one internal `OpenAISDK` pointed at Groq's
15
+ * `baseURL` with the `"groq"` provider label, and delegates `model()` /
16
+ * `embedder()` / `count()` to it.
17
+ *
18
+ * **Why a wrapper and not `OpenAISDK` directly?** Groq hosts *open*
19
+ * models whose ids are the upstream open-weight names (`llama-…`,
20
+ * `openai/gpt-oss-…`), not OpenAI's (`gpt-4o`, `o3`). The OpenAI
21
+ * adapter's capability inference keys on OpenAI prefixes and would never
22
+ * fire here, so every Groq model would come back with `vision`/
23
+ * `reasoning` silently `false`. `GroqSDK` fixes that by computing
24
+ * **this provider's own** vision/reasoning inference (see
25
+ * `known-models.ts`) and injecting the result as explicit capability
26
+ * config — which wins over the inner adapter's inference — plus a set of
27
+ * default per-model pricing rates. Everything else (transport, retries,
28
+ * streaming, structured output, error wrapping, usage accounting) is
29
+ * inherited unchanged from `OpenAISDK`.
30
+ *
31
+ * **Responsibility.**
32
+ * - Owns: one long-lived internal `OpenAISDK` (auth + Groq base URL) and
33
+ * this provider's capability + default-pricing inference.
34
+ * - Does NOT own: the wire protocol, streaming loop, structured-output
35
+ * mapping, or error wrapping — all inherited from `OpenAISDK`.
36
+ *
37
+ * Modeled as a class (see §4.2 of code-style.md — "long-lived state
38
+ * across many calls"), fronted by FP usage like the other adapters.
39
+ *
40
+ * @example
41
+ * const groq = new GroqSDK({ apiKey: process.env.GROQ_API_KEY! });
42
+ * const model = groq.model({ name: "llama-3.3-70b-versatile", temperature: 0.7 });
43
+ * const reasoner = groq.model({ name: "openai/gpt-oss-120b" }); // vision + reasoning auto-true
44
+ *
45
+ * @example
46
+ * // Compose into an `ai.groq` namespace for ergonomic agent wiring
47
+ * const ai = { agent, tool, systemPrompt, groq: new GroqSDK({ apiKey }) };
48
+ * const myAgent = ai.agent({ model: ai.groq.model({ name: "llama-3.1-8b-instant" }) });
49
+ */
50
+ declare class GroqSDK implements SDKAdapterContract {
51
+ /**
52
+ * The wrapped OpenAI-compatible adapter, pre-pointed at Groq's
53
+ * `baseURL` and labeled with the `"groq"` provider. All real wire work
54
+ * happens here; `GroqSDK` only enriches the per-model config before
55
+ * delegating.
56
+ */
57
+ private readonly openai;
58
+ private readonly provider;
59
+ private readonly pricing?;
60
+ constructor(config: GroqSDKConfig);
61
+ /**
62
+ * Build a `ModelContract` bound to the internal Groq-pointed client.
63
+ *
64
+ * The wrapper's whole job lives here: it computes **Groq's** vision /
65
+ * reasoning inference from the model id and forwards the result as
66
+ * *explicit* `vision` / `reasoning` config to the inner
67
+ * `OpenAISDK.model()`. Because explicit capability config wins over the
68
+ * inner adapter's OpenAI-prefix inference, the returned model reports
69
+ * the right capabilities even though the id isn't an OpenAI name. A
70
+ * caller-supplied `vision` / `reasoning` still wins over this
71
+ * inference (we only fill the gap when the field is omitted).
72
+ *
73
+ * Pricing resolution: per-model `config.pricing` wins; otherwise this
74
+ * SDK's `pricing` registry keyed by `config.name`; otherwise the
75
+ * adapter's built-in default rate for the model; otherwise `undefined`
76
+ * (no cost computed).
77
+ */
78
+ model(config: GroqModelConfig): ModelContract;
79
+ /**
80
+ * Rough offline token-count estimate. Delegated straight to the inner
81
+ * `OpenAISDK`, which uses the core character-heuristic
82
+ * (`approximateTokenCount`). Good for budgeting / quota guards, not for
83
+ * billing.
84
+ */
85
+ count(text: string, model?: string): Promise<number>;
86
+ /**
87
+ * Build an embedder bound to the internal client. Delegated to the
88
+ * inner `OpenAISDK`.
89
+ *
90
+ * IMPORTANT: as of mid-2026 Groq does **not** expose an
91
+ * OpenAI-compatible embeddings endpoint, so a live `.embed()` /
92
+ * `.embedMany()` call will fail at the provider. The method is kept for
93
+ * adapter symmetry; use `@warlock.js/ai-openai` or
94
+ * `@warlock.js/ai-google` for retrieval embeddings.
95
+ */
96
+ embedder(config: GroqEmbedderConfig): EmbedderContract;
97
+ }
98
+ //#endregion
99
+ export { GroqSDK };
100
+ //# sourceMappingURL=sdk.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/sdk.ts"],"mappings":";;;;;;AAgEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoF+D;;;;;;;;;;;cApFlD,OAAA,YAAmB,kBAAA;;;;;;;mBAOb,MAAA;EAAA,iBACA,QAAA;EAAA,iBACA,OAAA;cAEE,MAAA,EAAQ,aAAA;;;;;;;;;;;;;;;;;;EAqCpB,KAAA,CAAM,MAAA,EAAQ,eAAA,GAAkB,aAAA;;;;;;;EAsB1B,KAAA,CAAM,IAAA,UAAc,KAAA,YAAiB,OAAA;;;;;;;;;;;EAc3C,QAAA,CAAS,MAAA,EAAQ,kBAAA,GAAqB,gBAAA;AAAA"}
package/esm/sdk.mjs ADDED
@@ -0,0 +1,154 @@
1
+ import { GROQ_BASE_URL, GROQ_PROVIDER, inferReasoningCapability, inferVisionCapability } from "./known-models.mjs";
2
+ import { OpenAISDK } from "@warlock.js/ai-openai";
3
+
4
+ //#region ../@warlock.js/ai-groq/src/sdk.ts
5
+ /**
6
+ * Groq-backed implementation of `SDKAdapterContract`.
7
+ *
8
+ * **Role.** The package entry point for Groq-hosted open models
9
+ * (`llama-3.3-70b-versatile`, `llama-3.1-8b-instant`,
10
+ * `openai/gpt-oss-*`, `deepseek-r1-distill-*`, …) served on Groq's fast
11
+ * LPU hardware. Because Groq exposes the OpenAI Chat Completions wire
12
+ * protocol verbatim, `GroqSDK` is a **thin wrapper over the already
13
+ * battle-tested {@link OpenAISDK}** rather than a fresh transport
14
+ * implementation — it owns one internal `OpenAISDK` pointed at Groq's
15
+ * `baseURL` with the `"groq"` provider label, and delegates `model()` /
16
+ * `embedder()` / `count()` to it.
17
+ *
18
+ * **Why a wrapper and not `OpenAISDK` directly?** Groq hosts *open*
19
+ * models whose ids are the upstream open-weight names (`llama-…`,
20
+ * `openai/gpt-oss-…`), not OpenAI's (`gpt-4o`, `o3`). The OpenAI
21
+ * adapter's capability inference keys on OpenAI prefixes and would never
22
+ * fire here, so every Groq model would come back with `vision`/
23
+ * `reasoning` silently `false`. `GroqSDK` fixes that by computing
24
+ * **this provider's own** vision/reasoning inference (see
25
+ * `known-models.ts`) and injecting the result as explicit capability
26
+ * config — which wins over the inner adapter's inference — plus a set of
27
+ * default per-model pricing rates. Everything else (transport, retries,
28
+ * streaming, structured output, error wrapping, usage accounting) is
29
+ * inherited unchanged from `OpenAISDK`.
30
+ *
31
+ * **Responsibility.**
32
+ * - Owns: one long-lived internal `OpenAISDK` (auth + Groq base URL) and
33
+ * this provider's capability + default-pricing inference.
34
+ * - Does NOT own: the wire protocol, streaming loop, structured-output
35
+ * mapping, or error wrapping — all inherited from `OpenAISDK`.
36
+ *
37
+ * Modeled as a class (see §4.2 of code-style.md — "long-lived state
38
+ * across many calls"), fronted by FP usage like the other adapters.
39
+ *
40
+ * @example
41
+ * const groq = new GroqSDK({ apiKey: process.env.GROQ_API_KEY! });
42
+ * const model = groq.model({ name: "llama-3.3-70b-versatile", temperature: 0.7 });
43
+ * const reasoner = groq.model({ name: "openai/gpt-oss-120b" }); // vision + reasoning auto-true
44
+ *
45
+ * @example
46
+ * // Compose into an `ai.groq` namespace for ergonomic agent wiring
47
+ * const ai = { agent, tool, systemPrompt, groq: new GroqSDK({ apiKey }) };
48
+ * const myAgent = ai.agent({ model: ai.groq.model({ name: "llama-3.1-8b-instant" }) });
49
+ */
50
+ var GroqSDK = class {
51
+ constructor(config) {
52
+ const { baseURL, provider, pricing, ...clientOptions } = config;
53
+ this.provider = provider ?? "groq";
54
+ this.pricing = pricing;
55
+ this.openai = new OpenAISDK({
56
+ ...clientOptions,
57
+ baseURL: baseURL ?? "https://api.groq.com/openai/v1",
58
+ provider: this.provider,
59
+ pricing
60
+ });
61
+ }
62
+ /**
63
+ * Build a `ModelContract` bound to the internal Groq-pointed client.
64
+ *
65
+ * The wrapper's whole job lives here: it computes **Groq's** vision /
66
+ * reasoning inference from the model id and forwards the result as
67
+ * *explicit* `vision` / `reasoning` config to the inner
68
+ * `OpenAISDK.model()`. Because explicit capability config wins over the
69
+ * inner adapter's OpenAI-prefix inference, the returned model reports
70
+ * the right capabilities even though the id isn't an OpenAI name. A
71
+ * caller-supplied `vision` / `reasoning` still wins over this
72
+ * inference (we only fill the gap when the field is omitted).
73
+ *
74
+ * Pricing resolution: per-model `config.pricing` wins; otherwise this
75
+ * SDK's `pricing` registry keyed by `config.name`; otherwise the
76
+ * adapter's built-in default rate for the model; otherwise `undefined`
77
+ * (no cost computed).
78
+ */
79
+ model(config) {
80
+ const resolvedPricing = config.pricing ?? this.pricing?.[config.name] ?? defaultPricingFor(config.name);
81
+ return this.openai.model({
82
+ ...config,
83
+ vision: config.vision ?? inferVisionCapability(config.name),
84
+ reasoning: config.reasoning ?? inferReasoningCapability(config.name),
85
+ structuredOutput: config.structuredOutput ?? true,
86
+ pricing: resolvedPricing
87
+ });
88
+ }
89
+ /**
90
+ * Rough offline token-count estimate. Delegated straight to the inner
91
+ * `OpenAISDK`, which uses the core character-heuristic
92
+ * (`approximateTokenCount`). Good for budgeting / quota guards, not for
93
+ * billing.
94
+ */
95
+ async count(text, model) {
96
+ return this.openai.count(text, model);
97
+ }
98
+ /**
99
+ * Build an embedder bound to the internal client. Delegated to the
100
+ * inner `OpenAISDK`.
101
+ *
102
+ * IMPORTANT: as of mid-2026 Groq does **not** expose an
103
+ * OpenAI-compatible embeddings endpoint, so a live `.embed()` /
104
+ * `.embedMany()` call will fail at the provider. The method is kept for
105
+ * adapter symmetry; use `@warlock.js/ai-openai` or
106
+ * `@warlock.js/ai-google` for retrieval embeddings.
107
+ */
108
+ embedder(config) {
109
+ return this.openai.embedder(config);
110
+ }
111
+ };
112
+ /**
113
+ * Built-in default USD-per-1,000,000-token rates for the current Groq
114
+ * production models (mid-2026), used as the last fallback in `model()`'s
115
+ * pricing resolution. A per-model or SDK-level `pricing` entry always
116
+ * wins over these. Returns `undefined` for any unlisted id so cost stays
117
+ * an honest absence rather than a false zero. Update when Groq revises
118
+ * its public price list.
119
+ */
120
+ function defaultPricingFor(name) {
121
+ return GROQ_DEFAULT_PRICING[name];
122
+ }
123
+ /**
124
+ * Default per-million-token USD rates for known Groq models. Kept inline
125
+ * (not exported) so the public surface stays the inference helpers; a
126
+ * caller who wants different numbers supplies `pricing` on the SDK or
127
+ * per model.
128
+ */
129
+ const GROQ_DEFAULT_PRICING = {
130
+ "llama-3.3-70b-versatile": {
131
+ input: .59,
132
+ output: .79
133
+ },
134
+ "llama-3.1-8b-instant": {
135
+ input: .05,
136
+ output: .08
137
+ },
138
+ "openai/gpt-oss-120b": {
139
+ input: .15,
140
+ output: .75
141
+ },
142
+ "openai/gpt-oss-20b": {
143
+ input: .1,
144
+ output: .5
145
+ },
146
+ "deepseek-r1-distill-llama-70b": {
147
+ input: .75,
148
+ output: .99
149
+ }
150
+ };
151
+
152
+ //#endregion
153
+ export { GroqSDK };
154
+ //# sourceMappingURL=sdk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.mjs","names":[],"sources":["../../../../../../@warlock.js/ai-groq/src/sdk.ts"],"sourcesContent":["import type {\n EmbedderContract,\n ModelContract,\n ModelPricing,\n SDKAdapterContract,\n} from \"@warlock.js/ai\";\nimport { OpenAISDK } from \"@warlock.js/ai-openai\";\nimport type {\n GroqEmbedderConfig,\n GroqModelConfig,\n GroqSDKConfig,\n} from \"./config.type\";\nimport {\n GROQ_BASE_URL,\n GROQ_PROVIDER,\n inferReasoningCapability,\n inferVisionCapability,\n} from \"./known-models\";\n\n/**\n * Groq-backed implementation of `SDKAdapterContract`.\n *\n * **Role.** The package entry point for Groq-hosted open models\n * (`llama-3.3-70b-versatile`, `llama-3.1-8b-instant`,\n * `openai/gpt-oss-*`, `deepseek-r1-distill-*`, …) served on Groq's fast\n * LPU hardware. Because Groq exposes the OpenAI Chat Completions wire\n * protocol verbatim, `GroqSDK` is a **thin wrapper over the already\n * battle-tested {@link OpenAISDK}** rather than a fresh transport\n * implementation — it owns one internal `OpenAISDK` pointed at Groq's\n * `baseURL` with the `\"groq\"` provider label, and delegates `model()` /\n * `embedder()` / `count()` to it.\n *\n * **Why a wrapper and not `OpenAISDK` directly?** Groq hosts *open*\n * models whose ids are the upstream open-weight names (`llama-…`,\n * `openai/gpt-oss-…`), not OpenAI's (`gpt-4o`, `o3`). The OpenAI\n * adapter's capability inference keys on OpenAI prefixes and would never\n * fire here, so every Groq model would come back with `vision`/\n * `reasoning` silently `false`. `GroqSDK` fixes that by computing\n * **this provider's own** vision/reasoning inference (see\n * `known-models.ts`) and injecting the result as explicit capability\n * config — which wins over the inner adapter's inference — plus a set of\n * default per-model pricing rates. Everything else (transport, retries,\n * streaming, structured output, error wrapping, usage accounting) is\n * inherited unchanged from `OpenAISDK`.\n *\n * **Responsibility.**\n * - Owns: one long-lived internal `OpenAISDK` (auth + Groq base URL) and\n * this provider's capability + default-pricing inference.\n * - Does NOT own: the wire protocol, streaming loop, structured-output\n * mapping, or error wrapping — all inherited from `OpenAISDK`.\n *\n * Modeled as a class (see §4.2 of code-style.md — \"long-lived state\n * across many calls\"), fronted by FP usage like the other adapters.\n *\n * @example\n * const groq = new GroqSDK({ apiKey: process.env.GROQ_API_KEY! });\n * const model = groq.model({ name: \"llama-3.3-70b-versatile\", temperature: 0.7 });\n * const reasoner = groq.model({ name: \"openai/gpt-oss-120b\" }); // vision + reasoning auto-true\n *\n * @example\n * // Compose into an `ai.groq` namespace for ergonomic agent wiring\n * const ai = { agent, tool, systemPrompt, groq: new GroqSDK({ apiKey }) };\n * const myAgent = ai.agent({ model: ai.groq.model({ name: \"llama-3.1-8b-instant\" }) });\n */\nexport class GroqSDK implements SDKAdapterContract {\n /**\n * The wrapped OpenAI-compatible adapter, pre-pointed at Groq's\n * `baseURL` and labeled with the `\"groq\"` provider. All real wire work\n * happens here; `GroqSDK` only enriches the per-model config before\n * delegating.\n */\n private readonly openai: OpenAISDK;\n private readonly provider: string;\n private readonly pricing?: Record<string, ModelPricing>;\n\n public constructor(config: GroqSDKConfig) {\n const { baseURL, provider, pricing, ...clientOptions } = config;\n\n this.provider = provider ?? GROQ_PROVIDER;\n this.pricing = pricing;\n\n // Build the inner OpenAI-compatible client pointed at Groq. Forward\n // every other upstream ClientOptions (timeout, maxRetries,\n // defaultHeaders, fetch, …) verbatim — they type-check, so dropping\n // them would be a silent footgun. We pass `pricing` through too so\n // the inner registry stays a fallback, while THIS class's `model()`\n // layers Groq default rates on top.\n this.openai = new OpenAISDK({\n ...clientOptions,\n baseURL: baseURL ?? GROQ_BASE_URL,\n provider: this.provider,\n pricing,\n });\n }\n\n /**\n * Build a `ModelContract` bound to the internal Groq-pointed client.\n *\n * The wrapper's whole job lives here: it computes **Groq's** vision /\n * reasoning inference from the model id and forwards the result as\n * *explicit* `vision` / `reasoning` config to the inner\n * `OpenAISDK.model()`. Because explicit capability config wins over the\n * inner adapter's OpenAI-prefix inference, the returned model reports\n * the right capabilities even though the id isn't an OpenAI name. A\n * caller-supplied `vision` / `reasoning` still wins over this\n * inference (we only fill the gap when the field is omitted).\n *\n * Pricing resolution: per-model `config.pricing` wins; otherwise this\n * SDK's `pricing` registry keyed by `config.name`; otherwise the\n * adapter's built-in default rate for the model; otherwise `undefined`\n * (no cost computed).\n */\n public model(config: GroqModelConfig): ModelContract {\n const resolvedPricing =\n config.pricing ?? this.pricing?.[config.name] ?? defaultPricingFor(config.name);\n\n return this.openai.model({\n ...config,\n // Fill capability inference only when the caller didn't pin it —\n // explicit caller config always wins, then Groq inference, then\n // (inside OpenAISDK) the harmless OpenAI inference that won't match.\n vision: config.vision ?? inferVisionCapability(config.name),\n reasoning: config.reasoning ?? inferReasoningCapability(config.name),\n structuredOutput: config.structuredOutput ?? true,\n pricing: resolvedPricing,\n });\n }\n\n /**\n * Rough offline token-count estimate. Delegated straight to the inner\n * `OpenAISDK`, which uses the core character-heuristic\n * (`approximateTokenCount`). Good for budgeting / quota guards, not for\n * billing.\n */\n public async count(text: string, model?: string): Promise<number> {\n return this.openai.count(text, model);\n }\n\n /**\n * Build an embedder bound to the internal client. Delegated to the\n * inner `OpenAISDK`.\n *\n * IMPORTANT: as of mid-2026 Groq does **not** expose an\n * OpenAI-compatible embeddings endpoint, so a live `.embed()` /\n * `.embedMany()` call will fail at the provider. The method is kept for\n * adapter symmetry; use `@warlock.js/ai-openai` or\n * `@warlock.js/ai-google` for retrieval embeddings.\n */\n public embedder(config: GroqEmbedderConfig): EmbedderContract {\n return this.openai.embedder(config);\n }\n\n // NOTE: `image()` is intentionally NOT implemented. Groq hosts no\n // image-generation API, and `SDKAdapterContract.image` is optional —\n // its structural absence IS the capability guard, so\n // `ai.groq.image(...)` is a compile-time error rather than a runtime\n // surprise (mirrors Anthropic / Bedrock / Ollama).\n}\n\n/**\n * Built-in default USD-per-1,000,000-token rates for the current Groq\n * production models (mid-2026), used as the last fallback in `model()`'s\n * pricing resolution. A per-model or SDK-level `pricing` entry always\n * wins over these. Returns `undefined` for any unlisted id so cost stays\n * an honest absence rather than a false zero. Update when Groq revises\n * its public price list.\n */\nfunction defaultPricingFor(name: string): ModelPricing | undefined {\n return GROQ_DEFAULT_PRICING[name];\n}\n\n/**\n * Default per-million-token USD rates for known Groq models. Kept inline\n * (not exported) so the public surface stays the inference helpers; a\n * caller who wants different numbers supplies `pricing` on the SDK or\n * per model.\n */\nconst GROQ_DEFAULT_PRICING: Record<string, ModelPricing> = {\n \"llama-3.3-70b-versatile\": { input: 0.59, output: 0.79 },\n \"llama-3.1-8b-instant\": { input: 0.05, output: 0.08 },\n \"openai/gpt-oss-120b\": { input: 0.15, output: 0.75 },\n \"openai/gpt-oss-20b\": { input: 0.1, output: 0.5 },\n \"deepseek-r1-distill-llama-70b\": { input: 0.75, output: 0.99 },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAa,UAAb,MAAmD;CAWjD,AAAO,YAAY,QAAuB;EACxC,MAAM,EAAE,SAAS,UAAU,SAAS,GAAG,kBAAkB;EAEzD,KAAK,WAAW;EAChB,KAAK,UAAU;EAQf,KAAK,SAAS,IAAI,UAAU;GAC1B,GAAG;GACH,SAAS;GACT,UAAU,KAAK;GACf;EACF,CAAC;CACH;;;;;;;;;;;;;;;;;;CAmBA,AAAO,MAAM,QAAwC;EACnD,MAAM,kBACJ,OAAO,WAAW,KAAK,UAAU,OAAO,SAAS,kBAAkB,OAAO,IAAI;EAEhF,OAAO,KAAK,OAAO,MAAM;GACvB,GAAG;GAIH,QAAQ,OAAO,UAAU,sBAAsB,OAAO,IAAI;GAC1D,WAAW,OAAO,aAAa,yBAAyB,OAAO,IAAI;GACnE,kBAAkB,OAAO,oBAAoB;GAC7C,SAAS;EACX,CAAC;CACH;;;;;;;CAQA,MAAa,MAAM,MAAc,OAAiC;EAChE,OAAO,KAAK,OAAO,MAAM,MAAM,KAAK;CACtC;;;;;;;;;;;CAYA,AAAO,SAAS,QAA8C;EAC5D,OAAO,KAAK,OAAO,SAAS,MAAM;CACpC;AAOF;;;;;;;;;AAUA,SAAS,kBAAkB,MAAwC;CACjE,OAAO,qBAAqB;AAC9B;;;;;;;AAQA,MAAM,uBAAqD;CACzD,2BAA2B;EAAE,OAAO;EAAM,QAAQ;CAAK;CACvD,wBAAwB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACpD,uBAAuB;EAAE,OAAO;EAAM,QAAQ;CAAK;CACnD,sBAAsB;EAAE,OAAO;EAAK,QAAQ;CAAI;CAChD,iCAAiC;EAAE,OAAO;EAAM,QAAQ;CAAK;AAC/D"}
package/llms-full.txt ADDED
@@ -0,0 +1,122 @@
1
+ # Warlock AI Groq — full skills
2
+
3
+ > Package: `@warlock.js/ai-groq`
4
+
5
+ > Generated artifact. Concatenates every SKILL.md and reference file under `@warlock.js/ai-groq/skills/`. Re-run `node scripts/generate-llms.mjs` after any change.
6
+
7
+ ## setup-groq `@warlock.js/ai-groq/setup-groq/SKILL.md`
8
+
9
+ ---
10
+ name: setup-groq
11
+ 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.'
12
+ ---
13
+
14
+ # `@warlock.js/ai-groq`
15
+
16
+ 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.
17
+
18
+ ## Construction
19
+
20
+ ```ts
21
+ import { GroqSDK } from "@warlock.js/ai-groq";
22
+
23
+ // Common path — apiKey only. baseURL + provider default to Groq.
24
+ const groq = new GroqSDK({ apiKey: process.env.GROQ_API_KEY! });
25
+ ```
26
+
27
+ `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.
28
+
29
+ `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.
30
+
31
+ ## Producing a model
32
+
33
+ ```ts
34
+ groq.model({ name: "llama-3.3-70b-versatile" }) // flagship general-purpose text
35
+ groq.model({ name: "llama-3.1-8b-instant" }) // fastest / cheapest small text
36
+ groq.model({ name: "openai/gpt-oss-120b" }) // vision + reasoning auto-true
37
+ groq.model({ name: "deepseek-r1-distill-llama-70b" }) // reasoning auto-true
38
+ ```
39
+
40
+ 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.
41
+
42
+ ## Capabilities — what's auto-set
43
+
44
+ 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.
45
+
46
+ | Flag | Default |
47
+ | --- | --- |
48
+ | `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`). |
49
+ | `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. |
50
+ | `structuredOutput` | `true` — Groq accepts OpenAI-style `response_format`. |
51
+ | `promptCaching` | Inherited from the inner OpenAI adapter (`true`; read-side `cachedTokens` accounting). |
52
+
53
+ **Override `vision`, `reasoning`, or `structuredOutput` explicitly** via `.model({ name, vision?, reasoning?, structuredOutput? })` — an explicit value always wins over inference.
54
+
55
+ ```ts
56
+ groq.model({ name: "some-custom-llama", vision: true }) // force on for an unlisted multimodal id
57
+ groq.model({ name: "openai/gpt-oss-120b", reasoning: false }) // pin off
58
+ ```
59
+
60
+ ## Reasoning (gpt-oss / deepseek-r1 distill)
61
+
62
+ Reasoning models accept a discrete effort knob, forwarded by the inner adapter as OpenAI's `reasoning_effort`:
63
+
64
+ ```ts
65
+ const model = groq.model({ name: "deepseek-r1-distill-llama-70b" }); // reasoning auto-true
66
+ await model.complete(messages, { reasoning: { effort: "high" } }); // → reasoning_effort: "high"
67
+ ```
68
+
69
+ - `reasoning.effort` (`"low" | "medium" | "high"`) maps verbatim.
70
+ - `reasoning.maxTokens` has no Chat Completions equivalent and is ignored (same as the OpenAI adapter).
71
+ - When `capabilities.reasoning` is `false` (e.g. `llama-3.3-70b-versatile`), the option is dropped — never sent as an unsupported param.
72
+
73
+ ## Structured output & streaming
74
+
75
+ 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.
76
+
77
+ ## Embeddings — not available on Groq
78
+
79
+ 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.
80
+
81
+ 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).
82
+
83
+ ## Pricing — per-model registry + built-in defaults
84
+
85
+ `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.
86
+
87
+ ```ts
88
+ const groq = new GroqSDK({
89
+ apiKey,
90
+ pricing: {
91
+ "llama-3.3-70b-versatile": { input: 0.59, output: 0.79 }, // USD per 1M tokens
92
+ },
93
+ });
94
+ ```
95
+
96
+ 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.
97
+
98
+ ## Token counting
99
+
100
+ ```ts
101
+ await groq.count("some text") // approximate heuristic (delegated), not a real tokenizer
102
+ ```
103
+
104
+ Good for budgeting; not for billing.
105
+
106
+ ## Errors
107
+
108
+ 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.
109
+
110
+ ## When NOT to use this skill
111
+
112
+ - Embeddings or image generation — Groq has neither; use `@warlock.js/ai-openai` / `@warlock.js/ai-google`.
113
+ - OpenAI / Azure / OpenRouter — use `@warlock.js/ai-openai` (`setup-openai`); this wraps it but for Groq specifically.
114
+ - Anthropic — `@warlock.js/ai-anthropic`. Bedrock — `@warlock.js/ai-bedrock`. Gemini — `@warlock.js/ai-google`. Local Ollama — `@warlock.js/ai-ollama`.
115
+
116
+ ## See also
117
+
118
+ - [`@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
119
+ - [`@warlock.js/ai/run-ai-agent/SKILL.md`](@warlock.js/ai/run-ai-agent/SKILL.md) — passing the model into `ai.agent({...})`
120
+ - [`@warlock.js/ai/pick-ai-provider/SKILL.md`](@warlock.js/ai/pick-ai-provider/SKILL.md) — adapter comparison
121
+
122
+
package/llms.txt ADDED
@@ -0,0 +1,9 @@
1
+ # Warlock AI Groq
2
+
3
+ > Package: `@warlock.js/ai-groq`
4
+
5
+ > Groq adapter for @warlock.js/ai (OpenAI-compatible, thin wrapper over @warlock.js/ai-openai)
6
+
7
+ ## Skills
8
+
9
+ - [setup-groq](@warlock.js/ai-groq/setup-groq/SKILL.md): 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.