Skip to content

Class ZCL_LLM_CLIENT_OPENROUTER

AI Generated documentation.

Overview

Provides a specialized client implementation for interacting with OpenRouter's LLM API. Inherits core LLM client functionality from base class zcl_llm_client_base.

Key Public Methods:

  1. GET_CLIENT
  2. Factory method creating client instances
  3. Parameters: Client config (ZLLM_CLNT_CONFIG), provider config (ZLLM_PROVIDERS)
  4. Returns: ZIF_LLM_CLIENT interface reference

  5. CONSTRUCTOR

  6. Initializes client with configurations
  7. Triggers class initialization via inherited logic

Dependencies

  1. BAdI Implementation (ZCL_LLM_COMMON=>GET_LLM_BADI)
  2. Used for encryption/decryption of authentication credentials
  3. Encryption Class
  4. Dynamic resolution via BAdI for credential decryption
  5. HTTP Client Wrapper (ZCL_LLM_HTTP_CLIENT_WRAPPER)
  6. Handles HTTP connection management

Details

Method Flow

sequenceDiagram  
    participant Client  
    participant OpenRouterClient  
    participant HTTP_Wrapper  
    participant BAdI  
    participant Enc_Class  

    Client->>OpenRouterClient: get_client()  
    OpenRouterClient->>HTTP_Wrapper: get_client()  
    HTTP_Wrapper-->>OpenRouterClient: HTTP client  
    OpenRouterClient->>BAdI: get_encryption_impl()  
    BAdI-->>OpenRouterClient: enc_class  
    OpenRouterClient->>Enc_Class: decrypt()  

Key Redefined Methods

  1. GET_HTTP_CLIENT
  2. Retrieves preconfigured HTTP client from wrapper
  3. Sets OpenRouter-specific headers:

    • HTTP-Referer: Identifies calling application
    • X-Title: Client identification
  4. SET_AUTH

  5. Implements bearer token authentication
  6. Decrypts credentials using BAdI-resolved encryption implementation
  7. Handles both encrypted and plaintext authentication

  8. CREATE_STRUCTURED_OUTPUT

  9. Returns OpenRouter-specific JSON structure handler (ZCL_LLM_SO_JS_OR)

Security Handling

  • Authentication credentials are stored encrypted in PROVIDER_CONFIG-AUTH_ENCRYPTED
  • Decryption occurs only during runtime via injected encryption implementation

API Endpoints

  • Chat endpoint hardcoded to /chat/completions (OpenRouter standard)