Class OpenAiLanguageModel

java.lang.Object
dev.langchain4j.model.openai.OpenAiLanguageModel
All Implemented Interfaces:
dev.langchain4j.model.language.LanguageModel, dev.langchain4j.model.language.TokenCountEstimator

public class OpenAiLanguageModel extends Object implements dev.langchain4j.model.language.LanguageModel, dev.langchain4j.model.language.TokenCountEstimator
Represents an OpenAI language model with a completion interface, such as gpt-3.5-turbo-instruct. However, it's recommended to use OpenAiChatModel instead, as it offers more advanced features like function calling, multi-turn conversations, etc.
  • Constructor Details

  • Method Details

    • modelName

      public String modelName()
    • generate

      public dev.langchain4j.model.output.Response<String> generate(String prompt)
      Specified by:
      generate in interface dev.langchain4j.model.language.LanguageModel
    • estimateTokenCount

      public int estimateTokenCount(String prompt)
      Specified by:
      estimateTokenCount in interface dev.langchain4j.model.language.TokenCountEstimator
    • withApiKey

      @Deprecated public static OpenAiLanguageModel withApiKey(String apiKey)
      Deprecated.
      use builder() instead and explicitly set the model name and, if required, other parameters.
    • builder