Skip to content

add Sarvam AI provider (chat, text-to-speech, speech-to-text) - #5068

Merged
akshaydeo merged 10 commits into
maximhq:devfrom
Purvi09:feat/sarvam-provider
Jul 13, 2026
Merged

akshaydeo merged 10 commits into
maximhq:devfrom
Purvi09:feat/sarvam-provider

Conversation

@Purvi09

@Purvi09 Purvi09 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Sarvam AI as a built-in provider, closing #5051. Sarvam is a voice/LLM
provider focused on Indian languages (10 Indic languages + English), so this gives
Bifrost users a single integration for both text (chat) and voice (TTS/STT)
workloads in that language segment.

Changes

  • New provider package core/providers/sarvam/ covering three capabilities:
    • Chat completions — Sarvam's /v1/chat/completions is OpenAI-compatible, so
      this delegates to the shared openai.* handlers (base URL https://api.sarvam.ai,
      Authorization: Bearer). Mirrors the Cerebras pattern.
    • Text-to-Speech (Bulbul) — custom mapping: Sarvam returns JSON with base64-encoded
      audio in an audios[] array (not raw binary), which is decoded to bytes. Indic fields
      (target_language_code, speaker, pace, dict_id, …) are mapped from the request /
      ExtraParams.
    • Speech-to-Text (Saaras/Saarika) — custom mapping: multipart upload; response
      transcript/language_code/timestamps/diarized_transcript mapped onto Bifrost's
      transcription shape.
  • Core wiring: provider constant + StandardProviders (core/schemas/bifrost.go),
    registration in createBaseProvider (core/bifrost.go), dynamicallyConfigurableProviders
    (core/utils.go).
  • Schemas: transports/config.schema.json (provider + base_provider_type enum),
    docs/openapi/openapi.json (ModelProvider enum).
  • UI constants: ui/lib/constants/ — provider label, model placeholder, key-required
    flag, and brand icon.
  • Docs: new docs/providers/supported-providers/sarvam.mdx, nav entry in docs/docs.json,
    and a row in the provider support matrix (overview.mdx).
  • Tests/CI: integration test core/providers/sarvam/sarvam_test.go, test-harness key
    wiring (core/internal/llmtests/account.go), and SARVAM_API_KEY env references in
    pr-tests.yml / release-pipeline.yml.

Notable design decisions / trade-offs

  • Chat vs. voice split — chat reuses the shared OpenAI machinery (thin, low-risk);
    voice required hand-written mapping because Sarvam's TTS/STT are not OpenAI-compatible
    and use a different auth header (api-subscription-key).
  • Test scenarios are intentionally scoped to chat (SimpleChat, MultiTurnConversation),
    which pass in the comprehensive harness. Streaming and voice are verified manually (see
    below) but left out of the automated suite for concrete reasons documented in the test:
    • Sarvam's chat models are reasoning models that stream 500+ chunks, exceeding the
      harness's 500-chunk safety cap.
    • The generic voice harness can't supply Sarvam's required target_language_code for TTS.
  • Word timestamps / diarization are only returned by Sarvam's Batch API (not the sync
    endpoint used here); the mapping handles them defensively and this is noted in the docs.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

All three capabilities were verified end-to-end against the live Sarvam API.

Automated test (chat)

go version
# GOWORK ensures the local workspace (this PR's code) is used, not a published module
cd core
GOWORK="$(git rev-parse --show-toplevel)/go.work" SARVAM_API_KEY=<your-key> \
  go test ./providers/sarvam/ -run TestSarvam -timeout 3m
# expected: ok  github.com/maximhq/bifrost/core/providers/sarvam
# (skips automatically if SARVAM_API_KEY is unset)

# full build/vet
go build ./... && go vet ./providers/sarvam/

UI

cd ui
npm i
npm run typecheck
npm run build

Manual end-to-end (gateway)

Configure a Sarvam key (dashboard, or config.json with "value": "env.SARVAM_API_KEY"), then:

# Chat
curl -s http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"sarvam/sarvam-30b","messages":[{"role":"user","content":"Namaste"}]}'

# Text-to-Speech (target_language_code is required by Sarvam)
curl -s http://localhost:8080/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{"model":"sarvam/bulbul:v2","input":"Namaste","voice":"anushka","target_language_code":"hi-IN"}' \
  --output speech.wav

# Speech-to-Text
curl -s http://localhost:8080/v1/audio/transcriptions \
  -F "model=sarvam/saaras:v3" -F "file=@speech.wav"

Expected: a chat completion, a valid WAV file, and a JSON transcript respectively.

New env var

  • SARVAM_API_KEY — Sarvam API key. Used by config examples (env.SARVAM_API_KEY) and CI.
    The same key works for both chat (Bearer) and voice (api-subscription-key); Bifrost applies
    the correct header per operation. Maintainers: please add the SARVAM_API_KEY secret in
    repo settings so the provider's tests run in CI (until then they skip, not fail).

Screenshots/Recordings

Breaking changes

  • Yes
  • No

Related issues

Closes #5051

Security considerations

  • No new secret-handling paths: the API key uses the existing SecretVar / env. mechanism
    and is never logged.
  • Auth headers: Authorization: Bearer for chat, api-subscription-key for voice — applied
    server-side per request.
  • No new PII handling or sandboxing changes.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@Purvi09
Purvi09 requested a review from a team as a code owner July 9, 2026 12:35
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4fa5406-68b5-4296-a21b-8ecc60f4ac9d

📥 Commits

Reviewing files that changed from the base of the PR and between b203ea3 and acd4085.

📒 Files selected for processing (1)
  • transports/config.schema.json

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added Sarvam AI as a supported provider for chat, Responses, text-to-speech, and speech-to-text (voice streaming remains unsupported).
    • Updated supported-provider behavior to reflect Sarvam’s available capabilities (e.g., embeddings and other non-covered operations are not enabled).
  • Documentation

    • Added Sarvam provider documentation, updated the provider support matrix, and extended OpenAPI fallback lists.
  • Tests

    • Added Sarvam automated coverage for enabled scenarios, gated by the presence of a Sarvam API key.
  • Chores

    • Passed the Sarvam API key into test and release workflow environments.

Walkthrough

Adds the Sarvam AI provider with OpenAI-compatible chat and Responses support, custom speech and transcription APIs, provider registration, CI and configuration wiring, UI metadata, tests, and documentation.

Changes

Sarvam AI Provider Integration

Layer / File(s) Summary
Sarvam types and error parsing
core/providers/sarvam/types.go, core/providers/sarvam/errors.go
Defines Sarvam speech, transcription, and structured error models.
Provider construction and chat/completions
core/providers/sarvam/sarvam.go, core/providers/sarvam/cachedcontents.go
Adds provider construction, OpenAI-compatible model, chat, and Responses handling, plus unsupported-operation responses.
Custom TTS and STT mapping
core/providers/sarvam/speech.go, core/providers/sarvam/transcription.go, core/providers/sarvam/sarvam.go
Maps voice payloads, performs speech and transcription requests, and normalizes responses.
Provider registration, configuration, CI, UI, and tests
core/bifrost.go, core/schemas/bifrost.go, core/utils.go, core/internal/llmtests/account.go, core/providers/sarvam/sarvam_test.go, transports/config.schema.json, .github/workflows/*, ui/lib/constants/*
Registers Sarvam across provider selection, schemas, test infrastructure, configuration validation, CI secrets, UI metadata, and integration tests.
Documentation
docs/providers/supported-providers/*, docs/docs.json, docs/openapi/openapi.json
Adds Sarvam documentation, support-matrix and navigation entries, and fallback configuration metadata.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SarvamProvider
  participant SarvamAPI

  Client->>SarvamProvider: ChatCompletion or Responses
  SarvamProvider->>SarvamAPI: POST /v1/chat/completions
  SarvamAPI-->>SarvamProvider: Chat JSON
  SarvamProvider-->>Client: Bifrost response

  Client->>SarvamProvider: Speech or SpeechStream
  SarvamProvider->>SarvamAPI: POST /text-to-speech or /text-to-speech/stream
  SarvamAPI-->>SarvamProvider: Audio payload
  SarvamProvider-->>Client: Bifrost audio response

  Client->>SarvamProvider: Transcription
  SarvamProvider->>SarvamAPI: Multipart POST /speech-to-text
  SarvamAPI-->>SarvamProvider: Transcript and timing data
  SarvamProvider-->>Client: Normalized transcription
Loading

Possibly related PRs

Suggested reviewers: danpiths, roroghost17, tejasghatte

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding the Sarvam AI provider for chat, TTS, and STT.
Description check ✅ Passed The description matches the template well, covering summary, changes, testing, related issues, security, and checklist items.
Linked Issues check ✅ Passed The PR implements the linked scope: OpenAI-compatible chat, custom TTS, and multipart STT with the required response mapping.
Out of Scope Changes check ✅ Passed The extra docs, UI, schema, and CI updates are all directly related to making Sarvam a supported provider.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
core/providers/sarvam/speech.go Copies speech extra parameters before consuming Sarvam-specific fields.
core/providers/sarvam/sarvam.go Implements Sarvam provider methods and unsupported-operation handling.
core/providers/sarvam/transcription.go Maps Sarvam transcription request and response fields.
ui/lib/constants/config.ts Adds Sarvam UI metadata and model placeholder text.
docs/providers/supported-providers/sarvam.mdx Documents Sarvam capabilities and usage examples.

Reviews (10): Last reviewed commit: "Merge branch 'dev' into feat/sarvam-prov..." | Re-trigger Greptile

Comment thread core/providers/sarvam/speech.go Outdated
Comment thread core/providers/sarvam/transcription.go Outdated
Comment thread core/providers/sarvam/sarvam.go Outdated
Comment thread core/providers/sarvam/sarvam.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/release-pipeline.yml (1)

155-185: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Allow api.sarvam.ai:443 in the Sarvam test jobs

Add api.sarvam.ai:443 to the allowed-endpoints blocks in .github/workflows/release-pipeline.yml:155-185, 947-992, 1079-1115. test-core and both test-docker-image-* jobs set SARVAM_API_KEY, and the Sarvam client targets https://api.sarvam.ai, so harden-runner will block those calls otherwise.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release-pipeline.yml around lines 155 - 185, Add
api.sarvam.ai:443 to the allowed-endpoints lists used by the Sarvam test jobs in
release-pipeline.yml so hardened runner permits the Sarvam API calls. Update the
allowed-endpoints blocks for test-core and both test-docker-image jobs, keeping
the new endpoint alongside the other API host entries referenced by those job
definitions and the SARVAM_API_KEY usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/providers/sarvam/sarvam.go`:
- Around line 150-172: ChatCompletionStream is hardcoding the provider
identifier instead of using the provider’s configured key. Update
SarvamProvider.ChatCompletionStream to pass provider.GetProviderKey() into
openai.HandleOpenAIChatCompletionStreaming, matching ChatCompletion and
preserving correct behavior for custom base_provider_type configurations. Keep
the change localized to the ChatCompletionStream call site and avoid using the
literal schemas.Sarvam there.

---

Outside diff comments:
In @.github/workflows/release-pipeline.yml:
- Around line 155-185: Add api.sarvam.ai:443 to the allowed-endpoints lists used
by the Sarvam test jobs in release-pipeline.yml so hardened runner permits the
Sarvam API calls. Update the allowed-endpoints blocks for test-core and both
test-docker-image jobs, keeping the new endpoint alongside the other API host
entries referenced by those job definitions and the SARVAM_API_KEY usage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e18b615c-568f-4b30-b608-083628b5c30b

📥 Commits

Reviewing files that changed from the base of the PR and between 1f662f8 and 9046ba1.

📒 Files selected for processing (21)
  • .github/workflows/pr-tests.yml
  • .github/workflows/release-pipeline.yml
  • core/bifrost.go
  • core/internal/llmtests/account.go
  • core/providers/sarvam/cachedcontents.go
  • core/providers/sarvam/errors.go
  • core/providers/sarvam/sarvam.go
  • core/providers/sarvam/sarvam_test.go
  • core/providers/sarvam/speech.go
  • core/providers/sarvam/transcription.go
  • core/providers/sarvam/types.go
  • core/schemas/bifrost.go
  • core/utils.go
  • docs/docs.json
  • docs/openapi/openapi.json
  • docs/providers/supported-providers/overview.mdx
  • docs/providers/supported-providers/sarvam.mdx
  • transports/config.schema.json
  • ui/lib/constants/config.ts
  • ui/lib/constants/icons.tsx
  • ui/lib/constants/logs.ts

Comment thread core/providers/sarvam/sarvam.go
Comment thread core/providers/sarvam/transcription.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
core/providers/sarvam/sarvam.go (1)

106-128: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use GetPathFromContext for streaming chat requests.
ChatCompletionStream hardcodes /v1/chat/completions, so BifrostContextKeyURLPath is ignored for streaming while the unary path honors it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core/providers/sarvam/sarvam.go` around lines 106 - 128, ChatCompletionStream
is hardcoding the chat completions path, so the context-derived URL path
override is ignored for streaming. Update SarvamProvider.ChatCompletionStream to
use the same path resolution as the unary chat flow by calling
GetPathFromContext with the BifrostContext and falling back to the default
completions path only when no override is present. Keep the change localized in
ChatCompletionStream and preserve the existing
HandleOpenAIChatCompletionStreaming call structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@core/providers/sarvam/sarvam.go`:
- Around line 106-128: ChatCompletionStream is hardcoding the chat completions
path, so the context-derived URL path override is ignored for streaming. Update
SarvamProvider.ChatCompletionStream to use the same path resolution as the unary
chat flow by calling GetPathFromContext with the BifrostContext and falling back
to the default completions path only when no override is present. Keep the
change localized in ChatCompletionStream and preserve the existing
HandleOpenAIChatCompletionStreaming call structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b9fda956-d6d1-404e-abc1-f1a86eb779d9

📥 Commits

Reviewing files that changed from the base of the PR and between 9046ba1 and b01e781.

📒 Files selected for processing (4)
  • core/providers/sarvam/sarvam.go
  • core/providers/sarvam/speech.go
  • core/providers/sarvam/transcription.go
  • core/providers/sarvam/types.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • core/providers/sarvam/transcription.go
  • core/providers/sarvam/types.go
  • core/providers/sarvam/speech.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 9, 2026
@akshaydeo

Copy link
Copy Markdown
Contributor

@Purvi09 can you share the test report output here please?

@Purvi09

Purvi09 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@akshaydeo here is the test report

Test Report

Dashboard

Screenshot 2026-07-09 at 9 10 49 PM Screenshot 2026-07-09 at 9 12 21 PM

Live gateway tests (localhost:8080)

C1 — Chat sarvam-30b ·
Screenshot 2026-07-09 at 9 26 33 PM

curl -s http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" \
  -d '{"model":"sarvam/sarvam-30b","messages":[{"role":"user","content":"Namaste, reply in one short sentence"}]}'
content: "Namaste back to you."   model: sarvam-30b   usage: 18/640/658
routing: {provider: sarvam, model: sarvam-30b, key: sarvam_test}

C2 — Chat sarvam-105b ·
Screenshot 2026-07-09 at 9 27 17 PM

curl -s http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" \
  -d '{"model":"sarvam/sarvam-105b","messages":[{"role":"user","content":"Hi in one word"}]}'
content: "Namaste"   model: sarvam-105b   usage: 14/168/182
routing: {provider: sarvam, model: sarvam-105b, key: sarvam_test}

C3 — Responses API ·
Screenshot 2026-07-09 at 9 49 27 PM

curl -s http://localhost:8080/v1/responses -H "Content-Type: application/json" \
  -d '{"model":"sarvam/sarvam-30b","input":"Say hello in one word"}'

object: response   status: completed   output_text: "Hello"
routing: {provider: sarvam, model: sarvam-30b, key: sarvam_test}

C4 — Text-to-Speech (Bulbul) ·
Screenshot 2026-07-09 at 9 29 20 PM

sarvam-tts.zip

curl -s http://localhost:8080/v1/audio/speech -H "Content-Type: application/json" \
  -d '{"model":"sarvam/bulbul:v2","input":"Namaste, aap kaise hain?","voice":"anushka","target_language_code":"hi-IN"}' \
  --output tts.wav && file tts.wav
tts.wav: RIFF WAVE audio, Microsoft PCM, 16 bit, mono 22050 Hz

C5 — Speech-to-Text (Saaras) ·
Screenshot 2026-07-09 at 9 29 55 PM

curl -s http://localhost:8080/v1/audio/transcriptions -F "model=sarvam/saaras:v3" -F "file=@tts.wav"
text: "या मास तक आपके इस हैं।"   language: hi-IN
routing: {provider: sarvam, model: saaras:v3, key: sarvam_test}

Summary

Capability Result
Chat (sarvam-30b, sarvam-105b) ✅
Responses API ✅
Text-to-Speech ✅ (tts.wav)
Speech-to-Text ✅
Dashboard config ✅

@CLAassistant

CLAassistant commented Jul 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 3 committers have signed the CLA.

✅ Purvi09
❌ Pratham-Mishra04
❌ akshaydeo
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread core/providers/sarvam/transcription.go Outdated
Comment thread core/providers/sarvam/transcription.go Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 10, 2026
Comment thread core/providers/sarvam/speech.go Outdated
}

// Speech performs a text-to-speech request to Sarvam's API.
func (provider *SarvamProvider) Speech(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostSpeechRequest) (*schemas.BifrostSpeechResponse, *schemas.BifrostError) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can shift this method to sarvam.go - to maintain parity with the existing conventions

Comment thread core/providers/sarvam/transcription.go Outdated
}

// Transcription performs a speech-to-text request to Sarvam's API using multipart/form-data.
func (provider *SarvamProvider) Transcription(ctx *schemas.BifrostContext, key schemas.Key, request *schemas.BifrostTranscriptionRequest) (*schemas.BifrostTranscriptionResponse, *schemas.BifrostError) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, can shift this method to sarvam.go - to maintain parity with the existing conventions

Comment thread core/providers/sarvam/types.go Outdated
// SarvamError models Sarvam's error responses.
type SarvamError struct {
Error *sarvamErrorBody `json:"error"`
Detail json.RawMessage `json:"detail"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep this as a combined struct string and []string and unmarshal whichever is present, instead of unmarshaling at runtime in .Message() (we already do something similar for some other provider ig)

Comment thread core/providers/sarvam/sarvam.go
@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Hey @Purvi09 I have added some comments

Comment thread core/providers/sarvam/sarvam.go Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
core/providers/sarvam/sarvam.go (1)

227-229: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor: error string starts with capital per Go convention.

"Sarvam text-to-speech response contained no audio" starts with a capital letter. While "Sarvam" is a proper noun, Go convention prefers lowercase error strings. Consider rephrasing to keep the convention.

✏️ Suggested rewording
-		return nil, providerUtils.EnrichError(ctx, providerUtils.NewBifrostOperationError("Sarvam text-to-speech response contained no audio", nil), jsonData, body, provider.sendBackRawRequest, provider.sendBackRawResponse, latency)
+		return nil, providerUtils.EnrichError(ctx, providerUtils.NewBifrostOperationError("no audio in Sarvam text-to-speech response", nil), jsonData, body, provider.sendBackRawRequest, provider.sendBackRawResponse, latency)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core/providers/sarvam/sarvam.go` around lines 227 - 229, Update the error
message passed to NewBifrostOperationError in the Sarvam response validation to
begin with a lowercase word while preserving the existing provider context and
no-audio meaning.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@core/providers/sarvam/sarvam.go`:
- Around line 227-229: Update the error message passed to
NewBifrostOperationError in the Sarvam response validation to begin with a
lowercase word while preserving the existing provider context and no-audio
meaning.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0029d524-2845-4c10-bd05-a2d31d646db9

📥 Commits

Reviewing files that changed from the base of the PR and between 880da2c and 038447a.

📒 Files selected for processing (1)
  • core/providers/sarvam/sarvam.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 12, 2026
@Purvi09

Purvi09 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Pratham-Mishra04, thanks for the review! I've addressed all the comments:

1)Moved Speech() and Transcription() into sarvam.go
2)Flattened SarvamError - the detail field now resolves string-or-array at parse time
3)Implemented SpeechStream (streaming TTS via /text-to-speech/stream)
4)Verified the streaming - screenshot attached

Screenshot 2026-07-12 at 7 47 10 PM

Comment thread core/providers/sarvam/sarvam.go Outdated

// ListModels is not supported by the Sarvam provider.
func (provider *SarvamProvider) ListModels(ctx *schemas.BifrostContext, keys []schemas.Key, request *schemas.BifrostListModelsRequest) (*schemas.BifrostListModelsResponse, *schemas.BifrostError) {
return nil, providerUtils.NewUnsupportedOperationError(schemas.ListModelsRequest, provider.GetProviderKey())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread core/providers/sarvam/sarvam.go
@Purvi09

Purvi09 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Pratham-Mishra04 - added ListModels. /v1/models isn't in Sarvam's docs but is live and OpenAI-shaped, so it delegates to the shared OpenAI handler. Verified live (returns sarvam-30b, sarvam-105b), updated the support matrix and enabled the ListModels test.
Screenshot 2026-07-13 at 7 39 44 PM

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

awesome! reviewing

@akshaydeo
akshaydeo merged commit 4983b99 into maximhq:dev Jul 13, 2026
1 of 2 checks passed
akshaydeo added a commit that referenced this pull request Jul 14, 2026
* add Sarvam AI provider (chat, text-to-speech, speech-to-text)

* fix: address review feedback on Sarvam provider

* fix: enrich Sarvam STT decode/parse error paths with raw diagnostics

* refactor+feat: address review feedback on Sarvam provider

* fix: enrich Sarvam TTS malformed-response error paths

* feat: implement Sarvam ListModels

---------

Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Pratham Mishra <99235987+Pratham-Mishra04@users.noreply.github.com>
@coderabbitai coderabbitai Bot mentioned this pull request Jul 14, 2026
13 of 18 tasks
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…q#5068)

* add Sarvam AI provider (chat, text-to-speech, speech-to-text)

* fix: address review feedback on Sarvam provider

* fix: enrich Sarvam STT decode/parse error paths with raw diagnostics

* refactor+feat: address review feedback on Sarvam provider

* fix: enrich Sarvam TTS malformed-response error paths

* feat: implement Sarvam ListModels

---------

Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Pratham Mishra <99235987+Pratham-Mishra04@users.noreply.github.com>
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…q#5068)

* add Sarvam AI provider (chat, text-to-speech, speech-to-text)

* fix: address review feedback on Sarvam provider

* fix: enrich Sarvam STT decode/parse error paths with raw diagnostics

* refactor+feat: address review feedback on Sarvam provider

* fix: enrich Sarvam TTS malformed-response error paths

* feat: implement Sarvam ListModels

---------

Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
Co-authored-by: Pratham Mishra <99235987+Pratham-Mishra04@users.noreply.github.com>
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.

Add Sarvam AI provider — chat (OpenAI-compatible) + voice (TTS/STT, needs custom mapping)

4 participants