Class FromJson
java.lang.Object
bg.codexio.ai.openai.api.sdk.auth.FromJson
- All Implemented Interfaces:
SdkAuth
When instantiated and
and read as a resource (so it should reside in resources folder). The file name and the path type can be modified by calling some of the factory functions below.
credentials() is called,
already configured json file is scanned for credentials.
The default expected file name is openai-credentials.jsonand read as a resource (so it should reside in resources folder). The file name and the path type can be modified by calling some of the factory functions below.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected InputStreambg.codexio.ai.openai.api.payload.credentials.ApiCredentialsIn this implementation we first look for the apiKey in the provided JSON file
If this variable is missing, aNotValidAuthenticationMethoderror is thrown, as the authentication can never proceed without an api key.
If orgId or organizationId is configured, it is applied, otherwise the default empty value is used
CheckFromJson.AvailableKeysfor the correct naming.static FromJsonFactory method denoting a JSON file with absolute pathstatic FromJsonFactory method denoting a JSON resource file with relative path
-
Field Details
-
AUTH
-
-
Method Details
-
resource
Factory method denoting a JSON resource file with relative path- Parameters:
resourceFileName- the relative path of the JSON resource- Returns:
- new instance of the current class with configured credentials field
-
file
Factory method denoting a JSON file with absolute path- Parameters:
fullPathFileName- the absolute path of the JSON file- Returns:
- new instance of the current class with configured credentials field
-
credentials
public bg.codexio.ai.openai.api.payload.credentials.ApiCredentials credentials()In this implementation we first look for the apiKey in the provided JSON file
If this variable is missing, aNotValidAuthenticationMethoderror is thrown, as the authentication can never proceed without an api key.
If orgId or organizationId is configured, it is applied, otherwise the default empty value is used
CheckFromJson.AvailableKeysfor the correct naming.- Specified by:
credentialsin interfaceSdkAuth- Returns:
- ready for usage instance of
ApiCredentials
-
asInputStream
- Throws:
IOException
-