Namespace: openaicompatible
Functions
ChatTextGenerator
▸ ChatTextGenerator(settings
): OpenAICompatibleChatModel
Create a text generation model that calls an API that is compatible with OpenAI's chat API.
Please note that many providers implement the API with slight differences, which can cause unexpected errors and different behavior in less common scenarios.
Parameters
Name | Type |
---|---|
settings | OpenAICompatibleChatSettings |
Returns
See
https://platform.openai.com/docs/api-reference/chat/create
Example
const model = openaicompatible.ChatTextGenerator({
model: "provider-specific-model-name",
temperature: 0.7,
maxGenerationTokens: 500,
});
const text = await generateText({
model,
prompt: [
openai.ChatMessage.user(
"Write a short story about a robot learning to love:"
),
]
});
Defined in
packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleFacade.ts:114
CompletionTextGenerator
▸ CompletionTextGenerator(settings
): OpenAICompatibleCompletionModel
Create a text generation model that calls an API that is compatible with OpenAI's completion API.
Please note that many providers implement the API with slight differences, which can cause unexpected errors and different behavior in less common scenarios.
Parameters
Name | Type |
---|---|
settings | OpenAICompatibleChatSettings |
Returns
OpenAICompatibleCompletionModel
See
https://platform.openai.com/docs/api-reference/completions/create
Example
const model = openaicompatible.CompletionTextGenerator({
model: "provider-specific-model-name",
temperature: 0.7,
maxGenerationTokens: 500,
});
const text = await generateText({
model,
prompt: "Write a short story about a robot learning to love:"
});
Defined in
packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleFacade.ts:82
FireworksAIApi
▸ FireworksAIApi(settings?
): FireworksAIApiConfiguration
Configuration for the Fireworks.ai API.
It calls the API at https://api.fireworks.ai/inference/v1 and uses the FIREWORKS_API_KEY
api key environment variable.
Parameters
Name | Type |
---|---|
settings | Omit <BaseUrlPartsApiConfigurationOptions , "baseUrl" > & { baseUrl? : string | Partial <UrlParts > } & { apiKey? : string } |
Returns
See
https://readme.fireworks.ai/docs/openai-compatibility
Defined in
packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleFacade.ts:22
PerplexityApi
▸ PerplexityApi(settings?
): PerplexityApiConfiguration
Configuration for the Perplexity API.
It calls the API at https://api.perplexity.ai/ and uses the PERPLEXITY_API_KEY
api key environment variable.
Parameters
Name | Type |
---|---|
settings | Omit <BaseUrlPartsApiConfigurationOptions , "baseUrl" > & { baseUrl? : string | Partial <UrlParts > } & { apiKey? : string } |
Returns
See
https://docs.perplexity.ai/reference/post_chat_completions
Defined in
packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleFacade.ts:37
TextEmbedder
▸ TextEmbedder(settings
): OpenAICompatibleTextEmbeddingModel
Create a text embedding model that calls the OpenAI embedding API.
Parameters
Name | Type |
---|---|
settings | OpenAICompatibleTextEmbeddingModelSettings |
Returns
OpenAICompatibleTextEmbeddingModel
A new instance of OpenAITextEmbeddingModel.
See
https://platform.openai.com/docs/api-reference/embeddings
Example
const embeddings = await embedMany({
model: openaicompatible.TextEmbedder({ model: "provider-specific-model-name" }),
values: [
"At first, Nox didn't know what to do with the pup.",
"He keenly observed and absorbed everything around him, from the birds in the sky to the trees in the forest.",
]
});
Defined in
packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleFacade.ts:134
TogetherAIApi
▸ TogetherAIApi(settings?
): TogetherAIApiConfiguration
Configuration for the Together.ai API.
It calls the API at https://api.together.xyz/v1 and uses the TOGETHER_API_KEY
api key environment variable.
Parameters
Name | Type |
---|---|
settings | Omit <BaseUrlPartsApiConfigurationOptions , "baseUrl" > & { baseUrl? : string | Partial <UrlParts > } & { apiKey? : string } |
Returns
See
https://docs.together.ai/docs/openai-api-compatibility
Defined in
packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleFacade.ts:52