mem0ai/mem0 · error · ValueError

Unexpected response format from Sarvam API: {e}

Error message

Unexpected response format from Sarvam API: {e}

What it means

Error "Unexpected response format from Sarvam API: {e}" thrown in mem0ai/mem0.

Source

Thrown at mem0/llms/sarvam.py:94

        # Forward any per-call provider-specific parameters (LLMBase contract).
        params.update(kwargs)

        try:
            response = requests.post(url, headers=headers, json=params, timeout=30)
            response.raise_for_status()

            result = response.json()

            if "choices" in result and len(result["choices"]) > 0:
                return result["choices"][0]["message"]["content"]
            else:
                raise ValueError("No response choices found in Sarvam API response")

        except requests.exceptions.RequestException as e:
            raise RuntimeError(f"Sarvam API request failed: {e}")
        except KeyError as e:
            raise ValueError(f"Unexpected response format from Sarvam API: {e}")

View on GitHub (pinned to 001c235229)

Solutions

  1. Log the raw Sarvam API response to inspect its structure.
  2. Update the parsing code or pin the sarvam SDK version if the API shape changed.

When it happens

Trigger: Thrown at mem0/llms/sarvam.py:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/6a858751e4e4e446. Report an issue: GitHub.