## Purpose Define the Semantic Kernel integration layer — kernel registration, OpenAI connector configuration, plugin registration, and automatic function calling. ## Requirements ### Requirement: Semantic Kernel service registration The API backend SHALL register a Semantic Kernel `Kernel` instance in the ASP.NET Core DI container at startup, configured with an OpenAI chat completion connector. #### Scenario: Kernel registered at startup - **WHEN** the API application starts - **THEN** a `Kernel` instance is available for injection into controllers ### Requirement: OpenAI connector targets CLIProxyAPI proxy The Semantic Kernel OpenAI chat completion service SHALL be configured to use the existing CLIProxyAPI proxy endpoint as its base URL, reading the URL and model name from `appsettings.json`. #### Scenario: Connector uses configured endpoint - **WHEN** the kernel makes a chat completion request - **THEN** it sends the request to the URL specified in `ResponsesApi:BaseUrl` configuration #### Scenario: Model from configuration - **WHEN** the kernel makes a chat completion request - **THEN** it uses the model name specified in `ResponsesApi:Model` configuration ### Requirement: Plugin registration The API backend SHALL register extraction and validation plugins with the Kernel so they are available as tools for the LLM to invoke. #### Scenario: Plugins available as tools - **WHEN** the kernel is constructed - **THEN** all registered plugin functions appear in the tool list sent to the LLM ### Requirement: Auto function calling The Kernel SHALL be configured with automatic function calling enabled, allowing the LLM to invoke registered plugin functions without manual dispatch code. #### Scenario: LLM invokes tool automatically - **WHEN** the LLM decides to call a registered function during chat completion - **THEN** the kernel automatically executes the function and returns the result to the LLM