MCPcopy Index your code
hub / github.com/microsoft/TypeChat / createOpenAILanguageModel

Function createOpenAILanguageModel

typescript/src/model.ts:130–139  ·  view source on GitHub ↗
(apiKey: string, model: string, endPoint = "https://api.openai.com/v1/chat/completions", org = "", useResponsesApi?: boolean)

Source from the content-addressed store, hash-verified

128 * @returns An instance of `TypeChatLanguageModel`.
129 */
130export 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.

Callers 2

createLanguageModelFunction · 0.85
model.test.mjsFile · 0.85

Calls 3

isResponsesApiUrlFunction · 0.85
createFetchLanguageModelFunction · 0.85

Tested by

no test coverage detected