Class OpenAIServiceSettings.Builder

All Implemented Interfaces:
WithJson<OpenAIServiceSettings.Builder>, ObjectBuilder<OpenAIServiceSettings>
Enclosing class:
OpenAIServiceSettings

public static class OpenAIServiceSettings.Builder extends WithJsonObjectBuilderBase<OpenAIServiceSettings.Builder> implements ObjectBuilder<OpenAIServiceSettings>
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • apiKey

      public final OpenAIServiceSettings.Builder apiKey(@Nullable String value)
      A valid API key of your OpenAI account. You can find your OpenAI API keys in your OpenAI account under the API keys section.

      IMPORTANT: You must specify either api_key or client_secret. If you do not provide one or you provide more than one of them, you will receive an error when you try to create your endpoint.

      API name: api_key

    • clientId

      public final OpenAIServiceSettings.Builder clientId(@Nullable String value)
      For OAuth 2.0 authorization using the client credentials grant flow. The application ID that's assigned to your app.

      IMPORTANT: To configure OAuth 2.0, you must specify client_id, scopes, token_url, and client_secret together. If one of the fields is missing, you will receive an error when you try to create your endpoint.

      API name: client_id

    • clientSecret

      public final OpenAIServiceSettings.Builder clientSecret(@Nullable String value)
      For OAuth 2.0 authorization using the client credentials grant flow. The application secret that you created for your app.

      IMPORTANT: You must specify either api_key or client_secret. If you do not provide one or you provide more than one of them, you will receive an error when you try to create your endpoint.

      IMPORTANT: To configure OAuth 2.0, you must specify client_id, scopes, token_url, and client_secret together. If one of the fields is missing, you will receive an error when you try to create your endpoint.

      API name: client_secret

    • dimensions

      public final OpenAIServiceSettings.Builder dimensions(@Nullable Integer value)
      For a text_embedding or embedding task, the number of dimensions the resulting output embeddings should have. It is supported only in text-embedding-3 and later models. If it is not set, the OpenAI defined default for the model is used.

      API name: dimensions

    • modelId

      public final OpenAIServiceSettings.Builder modelId(String value)
      Required - The name of the model to use for the inference task. Refer to the OpenAI documentation for the list of available text embedding models.

      API name: model_id

    • organizationId

      public final OpenAIServiceSettings.Builder organizationId(@Nullable String value)
      The unique identifier for your organization. You can find the Organization ID in your OpenAI account under Settings > Organizations.

      API name: organization_id

    • rateLimit

      public final OpenAIServiceSettings.Builder rateLimit(@Nullable RateLimitSetting value)
      This setting helps to minimize the number of rate limit errors returned from OpenAI. The openai service sets a default number of requests allowed per minute depending on the task type. For text_embedding and embedding, it is set to 3000. For completion and chat_completion, it is set to 500.

      API name: rate_limit

    • rateLimit

      This setting helps to minimize the number of rate limit errors returned from OpenAI. The openai service sets a default number of requests allowed per minute depending on the task type. For text_embedding and embedding, it is set to 3000. For completion and chat_completion, it is set to 500.

      API name: rate_limit

    • scopes

      public final OpenAIServiceSettings.Builder scopes(List<String> list)
      For OAuth 2.0 authorization using the client credentials grant flow. The resource identifier of the resource you want. For example:
       "scopes": [
         "scope1",
         "scope2"
       ]
       
       

      IMPORTANT: To configure OAuth 2.0, you must specify client_id, scopes, token_url, and client_secret together. If one of the fields is missing, you will receive an error when you try to create your endpoint.

      API name: scopes

      Adds all elements of list to scopes.

    • scopes

      public final OpenAIServiceSettings.Builder scopes(String value, String... values)
      For OAuth 2.0 authorization using the client credentials grant flow. The resource identifier of the resource you want. For example:
       "scopes": [
         "scope1",
         "scope2"
       ]
       
       

      IMPORTANT: To configure OAuth 2.0, you must specify client_id, scopes, token_url, and client_secret together. If one of the fields is missing, you will receive an error when you try to create your endpoint.

      API name: scopes

      Adds one or more values to scopes.

    • similarity

      public final OpenAIServiceSettings.Builder similarity(@Nullable OpenAISimilarityType value)
      For a text_embedding or embedding task, the similarity measure. One of cosine, dot_product, l2_norm. Defaults to dot_product.

      API name: similarity

    • tokenUrl

      public final OpenAIServiceSettings.Builder tokenUrl(@Nullable String value)
      For OAuth 2.0 authorization using the client credentials grant flow. An OAuth2 token endpoint where Elasticsearch sends a request to exchange client credentials for an access token.

      IMPORTANT: To configure OAuth 2.0, you must specify client_id, scopes, token_url, and client_secret together. If one of the fields is missing, you will receive an error when you try to create your endpoint.

      API name: token_url

    • url

      public final OpenAIServiceSettings.Builder url(@Nullable String value)
      The URL endpoint to use for the requests. It can be changed for testing purposes. Default value is https://api.openai.com/v1/embeddings for a text_embedding or embedding task, https://api.openai.com/v1/chat/completions for a completion or chat_completion task.

      API name: url

    • self

      Specified by:
      self in class WithJsonObjectBuilderBase<OpenAIServiceSettings.Builder>
    • build

      public OpenAIServiceSettings build()
      Specified by:
      build in interface ObjectBuilder<OpenAIServiceSettings>
      Throws:
      NullPointerException - if some of the required fields are null.