Execute Groq major re-architecture and migration strategies with strangler fig pattern.
Use when migrating to or from Groq, performing major version upgrades,
or re-platforming existing integrations to Groq.
Trigger with phrases like "migrate groq", "groq migration",
"switch to groq", "groq replatform", "groq upgrade major".
Migrate to Groq from OpenAI, Anthropic, or other LLM providers. Groq's OpenAI-compatible API makes migration straightforward -- the primary changes are: different SDK import, different model IDs, and different response metadata. The reward is 10-50x faster inference.
Migration Complexity
Source
Complexity
Key Changes
OpenAI
Low
Import, model IDs, base URL -- API shape is identical
Anthropic
Medium
Different API shape, message format, streaming protocol
Local LLMs
Medium
Remove infra, add API calls
Other cloud (Bedrock, Vertex)
Medium
Remove cloud SDK, add groq-sdk
Instructions
Step 1: OpenAI to Groq Migration
// BEFORE: OpenAI
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const result = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
});
// AFTER: Groq (minimal changes)
import Groq from "groq-sdk";
const groq = new Groq({ apiKey: process.env.GROQ_API_KEY });
const result = await groq.chat.completions.create({
model: "llama-3.3-70b-versatile", // or "llama-3.1-8b-instant"
messages: [{ role: "user", content: "Hello" }],
});
// Same response shape: result.choices[0].message.content
// Run the same prompts through both providers to compare quality + speed
async function migrationBenchmark(prompts: string[]) {
const groq = new GroqProvider();
const openai = new OpenAIProvider();
for (const prompt of prompts) {
const messages = [{ role: "user" as const, content: prompt }];
const startGroq = performance.now();
const groqResult = await groq.complete(messages, "llama-3.3-70b-versatile", 256);
const groqMs = performance.now() - startGroq;
const startOAI = performance.now();
const oaiResult = await openai.complete(messages, "gpt-4o-mini", 256);
const oaiMs = performance.now() - startOAI;
console.log(`Prompt: "${prompt.slice(0, 50)}..."`);
console.log(` Groq: ${groqMs.toFixed(0)}ms | ${groqResult.tokens.total} tokens`);
console.log(` OpenAI: ${oaiMs.toFixed(0)}ms | ${oaiResult.tokens.total} tokens`);
console.log(` Speedup: ${(oaiMs / groqMs).toFixed(1)}x faster with Groq`);
console.log();
}
}
Step 7: Key Differences to Handle
Feature
OpenAI
Groq
SDK import
import OpenAI from "openai"
import Groq from "groq-sdk"
Env var
OPENAI_API_KEY
GROQ_API_KEY
Models
gpt-4o, gpt-4o-mini
llama-3.3-70b-versatile, llama-3.1-8b-instant
Embeddings
openai.embeddings.create()
Not available (use OpenAI or local)
Fine-tuning
Supported
Not available
Image generation
openai.images.generate()
Not available
Audio (STT)
openai.audio.transcriptions
groq.audio.transcriptions (faster)
Structured outputs
strict: true
strict: true (same format)
Tool calling
Supported
Supported (same format)
JSON mode
response_format: { type: "json_object" }
Same
Vision
gpt-4o with images
Llama 4 Scout/Maverick
Streaming
Supported
Supported (same SSE format)
Response usage
Standard fields
Adds queue_time, completion_time, total_time
Rollback Plan
set -euo pipefail
# Immediate rollback: flip feature flag
# groq_migration_pct = 0
# Verify:
# - All requests routing to OpenAI
# - Error rates returned to baseline
# - No Groq API calls in logs