Skip to content

fix(groq): add dedicated @ai-sdk/groq provider to avoid reasoning_content errors#13735

Merged
GeorgeDong32 merged 1 commit intomainfrom
DeJeune/add-ai-sdk-groq
Mar 23, 2026
Merged

fix(groq): add dedicated @ai-sdk/groq provider to avoid reasoning_content errors#13735
GeorgeDong32 merged 1 commit intomainfrom
DeJeune/add-ai-sdk-groq

Conversation

@DeJeune
Copy link
Copy Markdown
Collaborator

@DeJeune DeJeune commented Mar 23, 2026

What this PR does

Before this PR:
Groq uses the OpenAI-compatible provider (type: 'openai'). In AI SDK v6, the OpenAI provider sends reasoning_content in assistant messages by default, which Groq's API rejects on multi-turn conversations.

After this PR:
Groq uses the dedicated @ai-sdk/groq provider, which properly handles Groq's message format and does not send unsupported fields like reasoning_content.

Fixes #12327

Why we need it and why it was done in this way

The following tradeoffs were made:
Added @ai-sdk/groq as a new dependency (~small bundle impact via dynamic import).

The following alternatives were considered:

  • Stripping reasoning_content from messages before sending to Groq — fragile and would need to be maintained as message format evolves.
  • Using the dedicated @ai-sdk/groq provider (chosen) — the SDK handles Groq's API format natively, consistent with how other providers (Anthropic, Google, DeepSeek, etc.) have dedicated packages.

Breaking changes

None.

Special notes for your reviewer

  • Groq is registered as a dynamic provider in providerInitialization.ts (lazy-loaded), consistent with other non-core providers like Mistral, Cerebras, Perplexity.
  • A static mapping groq: 'groq' is added in factory.ts to ensure the provider ID resolves to the dedicated provider instead of falling through to OpenAI compatible.

Checklist

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Documentation: N/A — internal provider routing change, no user-facing feature change.
  • Self-review: I have reviewed my own code before requesting review from others

Release note

Fix Groq multi-turn conversation errors caused by unsupported `reasoning_content` field by switching to the dedicated `@ai-sdk/groq` provider.

…tent errors

Groq rejects `reasoning_content` in assistant messages, which the
OpenAI-compatible provider sends by default in AI SDK v6. Switch Groq
to use the dedicated @ai-sdk/groq provider so the SDK properly handles
Groq's message format on multi-turn conversations.

Closes #12327

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: suyao <[email protected]>
@DeJeune DeJeune requested review from EurFelux and eeee0717 March 23, 2026 07:49
@GeorgeDong32 GeorgeDong32 merged commit d03388a into main Mar 23, 2026
9 checks passed
@GeorgeDong32 GeorgeDong32 deleted the DeJeune/add-ai-sdk-groq branch March 23, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants