llm

Sarvam LLM service implementation using OpenAI-compatible interface.

class pipecat.services.sarvam.llm.SarvamLLMSettings(model: str | None | _NotGiven = <factory>, extra: dict[str, Any]=<factory>, system_instruction: str | None | _NotGiven = <factory>, temperature: float | None | _NotGiven | NotGiven = <factory>, max_tokens: int | None | _NotGiven | NotGiven = <factory>, top_p: float | None | _NotGiven | NotGiven = <factory>, top_k: int | None | _NotGiven = <factory>, frequency_penalty: float | None | _NotGiven | NotGiven = <factory>, presence_penalty: float | None | _NotGiven | NotGiven = <factory>, seed: int | None | _NotGiven | NotGiven = <factory>, filter_incomplete_user_turns: bool | None | _NotGiven = <factory>, user_turn_completion_config: UserTurnCompletionConfig | None | _NotGiven = <factory>, max_completion_tokens: int | _NotGiven | NotGiven = <factory>, wiki_grounding: bool | None | _NotGiven = <factory>, reasoning_effort: Literal['low', 'medium', 'high'] | None | ~pipecat.services.settings._NotGiven=<factory>)[source]

Bases: OpenAILLMSettings

Settings for SarvamLLMService.

Parameters:
  • wiki_grounding – Sarvam wiki grounding toggle.

  • reasoning_effort – Reasoning effort level (low, medium, high).

wiki_grounding: bool | None | _NotGiven
reasoning_effort: Literal['low', 'medium', 'high'] | None | _NotGiven
class pipecat.services.sarvam.llm.SarvamLLMService(*, api_key: str, base_url: str = 'https://api.sarvam.ai/v1', settings: SarvamLLMSettings | None = None, default_headers: Mapping[str, str] | None = None, **kwargs)[source]

Bases: OpenAILLMService

A service for interacting with Sarvam’s API using the OpenAI-compatible interface.

This service extends OpenAILLMService to connect to Sarvam’s API endpoint while maintaining full compatibility with OpenAI’s interface and functionality.

supports_developer_role = False

Whether this service’s API supports the “developer” message role.

OpenAI’s native API supports it, but some OpenAI-compatible services (e.g. Cerebras) do not. Subclasses that don’t support it should set this to False, which causes the adapter to convert “developer” messages to “user” messages before sending them to the API.

Settings

alias of SarvamLLMSettings

__init__(*, api_key: str, base_url: str = 'https://api.sarvam.ai/v1', settings: SarvamLLMSettings | None = None, default_headers: Mapping[str, str] | None = None, **kwargs)[source]

Initialize Sarvam LLM service.

Parameters:
  • api_key – Sarvam API key used for both OpenAI auth and Sarvam subscription header.

  • base_url – Sarvam OpenAI-compatible base URL.

  • settings – Runtime-updatable settings.

  • default_headers – Additional HTTP headers to include in requests.

  • **kwargs – Additional keyword arguments passed to OpenAILLMService.

create_client(api_key=None, base_url=None, organization=None, project=None, default_headers=None, **kwargs)[source]

Create OpenAI-compatible client for Sarvam API endpoint.

Ensures Sarvam auth and SDK identification headers are always attached.

build_chat_completion_params(params_from_context: OpenAILLMInvocationParams) dict[source]

Build parameters for Sarvam chat completion request.

Starts from OpenAI-compatible defaults, then removes unsupported request fields and applies Sarvam-specific options.