Repository: livekit/agents
File: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py (Python)

Code before:
                self.__headers = _headers

            def chat(
                self,
                *,
                chat_ctx: ChatContext,
                tools: list[FunctionTool | RawFunctionTool] | None = None,
                conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
                parallel_tool_calls: NotGivenOr[bool] = NOT_GIVEN,
                tool_choice: NotGivenOr[ToolChoice] = NOT_GIVEN,
                response_format: NotGivenOr[
                    completion_create_params.ResponseFormat | type[llm_utils.ResponseFormatT]
                ] = NOT_GIVEN,
                extra_kwargs: NotGivenOr[dict[str, Any]] = NOT_GIVEN,
            ) -> LLMStream:
                # Merge provided extras with OpenRouter-specific defaults
                merged: dict[str, Any] = {}
                if is_given(extra_kwargs):
                    merged.update(extra_kwargs)

                # Add OpenRouter-specific body parameters
                if self.__or_body:
                    body = dict(self.__or_body)
                    if "extra_body" in merged and isinstance(merged["extra_body"], dict):
                        body.update(merged["extra_body"])
                    merged["extra_body"] = body

                # Add OpenRouter-specific headers
                if self.__headers:
                    headers = dict(self.__headers)
                    if "extra_headers" in merged and isinstance(merged["extra_headers"], dict):
                        headers.update(merged["extra_headers"])
                    merged["extra_headers"] = headers

                return super().chat(
                    chat_ctx=chat_ctx,
                    tools=tools,
                    conn_options=conn_options,
                    parallel_tool_calls=parallel_tool_calls,
                    tool_choice=tool_choice if tool_choice is not None else NOT_GIVEN,
                    response_format=response_format,
                    extra_kwargs=merged,
                )

        return _OpenRouterLLM(
            model=model,
            api_key=api_key,
            client=client,
            base_url=base_url,
            user=user,
            temperature=temperature,

Review comment (suggestion):
I think we can expose `extra_body`, `extra_headers`, and `extra_query` to the base LLM class so you don't need to  create a OpenRouterLLM here.

Code after:
        reasoning_effort: NotGivenOr[ReasoningEffort] = NOT_GIVEN,
        safety_identifier: NotGivenOr[str] = NOT_GIVEN,
        prompt_cache_key: NotGivenOr[str] = NOT_GIVEN,
        top_p: NotGivenOr[float] = NOT_GIVEN,
    ) -> LLM:
        """
        Create a new instance of DeepSeek LLM.

        ``api_key`` must be set to your DeepSeek API key, either using the argument or by setting
        the ``DEEPSEEK_API_KEY`` environmental variable.
        """

        api_key = api_key or os.environ.get("DEEPSEEK_API_KEY")
        if api_key is None:
            raise ValueError(
                "DeepSeek API key is required, either as argument or set DEEPSEEK_API_KEY environmental variable"  # noqa: E501
            )

        return LLM(
            model=model,
            api_key=api_key,
            base_url=base_url,
            client=client,
            user=user,
            temperature=temperature,
            parallel_tool_calls=parallel_tool_calls,
            tool_choice=tool_choice,
            reasoning_effort=reasoning_effort,
            safety_identifier=safety_identifier,
            prompt_cache_key=prompt_cache_key,
            top_p=top_p,
        )

    @staticmethod
    def with_octo(
        *,
        model: str | OctoChatModels = "llama-2-13b-chat",
        api_key: str | None = None,
        base_url: str = "https://text.octoai.run/v1",
        client: openai.AsyncClient | None = None,
        user: NotGivenOr[str] = NOT_GIVEN,
        temperature: NotGivenOr[float] = NOT_GIVEN,
        parallel_tool_calls: NotGivenOr[bool] = NOT_GIVEN,
        tool_choice: ToolChoice = "auto",
        reasoning_effort: NotGivenOr[ReasoningEffort] = NOT_GIVEN,
        safety_identifier: NotGivenOr[str] = NOT_GIVEN,
        prompt_cache_key: NotGivenOr[str] = NOT_GIVEN,
        top_p: NotGivenOr[float] = NOT_GIVEN,
    ) -> LLM:
        """
        Create a new instance of OctoAI LLM.