Class FromEnvironment

java.lang.Object
bg.codexio.ai.openai.api.sdk.auth.FromEnvironment
All Implemented Interfaces:
SdkAuth

public class FromEnvironment extends Object implements SdkAuth
When instantiated and credentials() is called, series of environment variables will be scanned to provide necessary ApiCredentials. The expected environment variables names can be checked in AvailableEnvironmentVariables
  • Field Details

  • Method Details

    • credentials

      public bg.codexio.ai.openai.api.payload.credentials.ApiCredentials credentials()
      In this implementation we first look for the api key in the environment variables
      If this variable is missing, a NotValidAuthenticationMethod error is thrown, as the authentication can never proceed without an api key.
      If organization id is configured, it is applied, otherwise the default empty value is used
      Specified by:
      credentials in interface SdkAuth
      Returns:
      ready for usage instance of ApiCredentials
    • getEnv

      protected String getEnv(String key)