The constructor accepts an options object with the following properties:
apiKey
: The API key for Langtail. This is required.baseURL
(optional): The base URL for the Langtail API.doNotRecord
(optional): A boolean indicating whether to record the API calls.organization
(optional): The organization ID.project
(optional): The project ID.fetch
(optional): The fetch function to use for making HTTP requests. It is passed to openAI client under the hood.onResponse
(optional): A callback that is called with the response object before it is returned. It can be used for logging or debugging purposes.
completions
: An instance of theLangtailPrompts
class.chat
: An object containing acompletions
object with acreate
method.
This method accepts two parameters:
body
: An object that can be of typeChatCompletionCreateParamsNonStreaming & ILangtailExtraProps
,ChatCompletionCreateParamsStreaming & ILangtailExtraProps
,ChatCompletionCreateParamsBase & ILangtailExtraProps
, orChatCompletionCreateParams & ILangtailExtraProps
.options
(optional): OpenAICore.RequestOptions
object
It returns a promise that resolves to a ChatCompletion
or a Stream<ChatCompletionChunk>
depending whether you are using streaming or not.
- Throws an error if the
apiKey
is not provided in the options object or as an environment variable.
The constructor accepts an options object with the following properties:
apiKey
: The API key for Langtail. This is required.baseURL
(optional): The base URL for the Langtail API.organization
(optional): The organization ID.project
(optional): The project ID.fetch
(optional): The fetch function to use for making HTTP requests. It is passed to openAI client under the hood.onResponse
(optional): A callback that is called with the response object before it is returned. It can be used for logging or debugging purposes.
apiKey
: The API key for Langtail.baseUrl
(optional): The base URL for the Langtail API.options
(optional): An object containing the options for the Langtail API.
This method accepts an IRequestParams
or IRequestParamsStream
object and returns a promise that resolves to an OpenAIResponseWithHttp
or a StreamResponseType
depending on whether you use streaming or not.
This method accepts one parameter with these fields:
prompt
: A string representing the prompt.environment
(optional): AnEnvironment
string identifier. Accepts values:"preview" | "staging" | "production"
. Defaults toproduction
version
(optional): string for version. Necessary for preview environment
Returns playground state defined here:
Line 94 in 48e2690
- Throws an error if the fetch operation fails.
- Throws an error if there is no body in the response when streaming is enabled.