Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 302
feat(ai-groq): Add Groq adapter package#332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/ai-groq': minor | ||
| --- | ||
| Adds a new @tanstack/ai-groq package(minor release), a Groq AI adapter for TanStack AI. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # @tanstack/ai-groq | ||
| Groq adapter for TanStack AI | ||
| ## Installation | ||
| ```bash | ||
| npm install @tanstack/ai-groq | ||
| # or | ||
| pnpm add @tanstack/ai-groq | ||
| # or | ||
| yarn add @tanstack/ai-groq | ||
| ``` | ||
| ## Setup | ||
| Get your API key from [Groq Console](https://console.groq.com) and set it as an environment variable: | ||
| ```bash | ||
| export GROQ_API_KEY="gsk_..." | ||
| ``` | ||
| ## Usage | ||
| ### Text/Chat Adapter | ||
| ```typescript | ||
| import { groqText } from '@tanstack/ai-groq' | ||
| import { generate } from '@tanstack/ai' | ||
| const adapter = groqText('llama-3.3-70b-versatile') | ||
| const result = await generate({ | ||
| adapter, | ||
| model: 'llama-3.3-70b-versatile', | ||
| messages: [ | ||
| { role: 'user', content: 'Explain quantum computing in simple terms' }, | ||
| ], | ||
| }) | ||
| console.log(result.text) | ||
| ``` | ||
| ### With Explicit API Key | ||
| ```typescript | ||
| import { createGroqText } from '@tanstack/ai-groq' | ||
| const adapter = createGroqText('llama-3.3-70b-versatile', 'gsk_api_key') | ||
| ``` | ||
| ## Supported Models | ||
| ### Chat Models | ||
| - `llama-3.3-70b-versatile` - Meta Llama 3.3 70B (131k context) | ||
| - `llama-3.1-8b-instant` - Meta Llama 3.1 8B (131k context) | ||
| - `meta-llama/llama-4-maverick-17b-128e-instruct` - Meta Llama 4 Maverick (vision) | ||
| - `meta-llama/llama-4-scout-17b-16e-instruct` - Meta Llama 4 Scout | ||
| - `meta-llama/llama-guard-4-12b` - Meta Llama Guard 4 (content moderation, vision) | ||
| - `meta-llama/llama-prompt-guard-2-86m` - Meta Llama Prompt Guard (content moderation) | ||
| - `meta-llama/llama-prompt-guard-2-22m` - Meta Llama Prompt Guard (content moderation) | ||
| - `openai/gpt-oss-120b` - GPT OSS 120B (reasoning, tools, search) | ||
| - `openai/gpt-oss-20b` - GPT OSS 20B (reasoning, search) | ||
| - `openai/gpt-oss-safeguard-20b` - GPT OSS Safeguard 20B (content moderation, reasoning) | ||
| - `moonshotai/kimi-k2-instruct-0905` - Kimi K2 Instruct (262k context) | ||
| - `qwen/qwen3-32b` - Qwen3 32B (reasoning, tools) | ||
| ## Features | ||
| - ✅ Streaming chat completions | ||
| - ✅ Structured output (JSON Schema) | ||
| - ✅ Function/tool calling | ||
| - ✅ Multimodal input (text + images for vision models) | ||
| - ❌ Embeddings (not supported by Groq) | ||
| - ❌ Image generation (not supported by Groq) | ||
| ## Tree-Shakeable Adapters | ||
| This package uses tree-shakeable adapters, so you only import what you need: | ||
| ```typescript | ||
| // Only imports text adapter | ||
| import { groqText } from '@tanstack/ai-groq' | ||
| ``` | ||
| This keeps your bundle size small! | ||
| ## License | ||
| MIT | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "name": "@tanstack/ai-groq", | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "description": "Groq adapter for TanStack AI", | ||
| "author": "", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/TanStack/ai.git", | ||
| "directory": "packages/typescript/ai-groq" | ||
| }, | ||
| "module": "./dist/esm/index.js", | ||
| "types": "./dist/esm/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/esm/index.d.ts", | ||
| "import": "./dist/esm/index.js" | ||
| } | ||
| }, | ||
Comment on lines
+15
to
+20
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add Line 15 currently exports only Proposed export map adjustment "exports": {
".": {
"types": "./dist/esm/index.d.ts",
"import": "./dist/esm/index.js"
+ },+ "./adapters/text": {+ "types": "./dist/esm/adapters/text.d.ts",+ "import": "./dist/esm/adapters/text.js"
}
},🤖 Prompt for AI Agents | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
| ], | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "clean": "premove ./build ./dist", | ||
| "lint:fix": "eslint ./src --fix", | ||
| "test:build": "publint --strict", | ||
| "test:eslint": "eslint ./src", | ||
| "test:lib": "vitest run", | ||
| "test:lib:dev": "pnpm test:lib --watch", | ||
| "test:types": "tsc" | ||
| }, | ||
| "keywords": [ | ||
| "ai", | ||
| "groq", | ||
| "tanstack", | ||
| "adapter" | ||
| ], | ||
| "devDependencies": { | ||
| "@vitest/coverage-v8": "4.0.14", | ||
| "vite": "^7.2.7" | ||
| }, | ||
| "peerDependencies": { | ||
| "@tanstack/ai": "workspace:^", | ||
| "zod": "^4.0.0" | ||
| }, | ||
| "dependencies": { | ||
| "groq-sdk": "^0.37.0" | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid secret-like literal API key examples.
Line 49 shows a hardcoded key-looking string. This pattern is often copy-pasted into source code; prefer env-backed examples to reduce accidental secret exposure.
Suggested doc tweak
import { createGroqText } from '@tanstack/ai-groq' -const adapter = createGroqText('llama-3.3-70b-versatile', 'gsk_api_key')+const adapter = createGroqText('llama-3.3-70b-versatile', process.env.GROQ_API_KEY!)📝 Committable suggestion
🤖 Prompt for AI Agents