(apiKey: string, model: string, endPoint = "https://api.openai.com/v1/chat/completions", org = "", useResponsesApi?: boolean)
| 128 | * @returns An instance of `TypeChatLanguageModel`. |
| 129 | */ |
| 130 | export function createOpenAILanguageModel(apiKey: string, model: string, endPoint = "https://api.openai.com/v1/chat/completions", org = "", useResponsesApi?: boolean): TypeChatLanguageModel { |
| 131 | const headers = { |
| 132 | "Authorization": `Bearer ${apiKey}`, |
| 133 | "OpenAI-Organization": org |
| 134 | }; |
| 135 | if ((useResponsesApi ?? isResponsesApiUrl(endPoint))) { |
| 136 | return createResponsesFetchLanguageModel(endPoint, headers, { model }); |
| 137 | } |
| 138 | return createFetchLanguageModel(endPoint, headers, { model }); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Creates a language model encapsulation of an Azure OpenAI REST API endpoint. |
no test coverage detected