OpenAILLMClient

open class OpenAILLMClient(apiKey: String, settings: OpenAIClientSettings = OpenAIClientSettings(), baseClient: HttpClient = HttpClient()) : LLMEmbeddingProvider, LLMClient(source)

Implementation of LLMClient for OpenAI API. Uses Ktor HttpClient to communicate with the OpenAI API.

Parameters

apiKey

The API key for the OpenAI API

settings

The base URL and timeouts for the OpenAI API, defaults to "https://api.openai.com" and 900 s

Constructors

Link copied to clipboard
constructor(apiKey: String, settings: OpenAIClientSettings = OpenAIClientSettings(), baseClient: HttpClient = HttpClient())

Functions

Link copied to clipboard
open suspend override fun embed(text: String, model: LLModel): List<Double>

Embeds the given text using the OpenAI embeddings API.

Link copied to clipboard
open suspend override fun execute(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>): List<Message.Response>
Link copied to clipboard
open suspend override fun executeStreaming(prompt: Prompt, model: LLModel): Flow<String>