generative-ts

Function createMistralModelProvider

  • Creates a Mistral ModelProvider with the MistralAiApi

    import { createMistralModelProvider } from "generative-ts";

    const mistralLarge = createMistralModelProvider({
    modelId: "mistral-large-latest", // Mistral defined model ID
    // you can explicitly pass auth here, otherwise by default it is read from process.env
    });

    const response = await mistralLarge.sendRequest({
    $prompt: "Brief History of NY Mets:"
    // all other Mistral ChatCompletion API options available here
    });

    console.log(response.choices[0]?.message.content);

    Provider Setup and Notes

    Create an API account at Mistral

    Obtain a Mistral API key and either pass them explicitly in auth or set them in the environment as MISTRAL_API_KEY

    Model Parameters

    Model IDs

    Type Parameters

    • THttpClientOptions = HttpClientOptions

    Parameters

    • params: {
          auth?: MistralAuthConfig;
          client?: HttpClient<THttpClientOptions>;
          modelId: string;
      }
      • Optional auth?: MistralAuthConfig

        Authentication configuration for Mistral. If not supplied, it will be loaded from the environment.

      • Optional client?: HttpClient<THttpClientOptions>

        HTTP client to use for requests. If not supplied, the built-in fetch-based implementation will be used.

      • modelId: string

        The model ID as defined by Mistral.

    Returns HttpModelProvider<MistralAiOptions, MistralAiResponse, THttpClientOptions, {
        modelId: string;
    }>

    The Mistral Model Provider with the MistralAiApi

    See

    Throws

    If no auth is passed and MISTRAL_API_KEY is not found in process.env

    Example: Usage

    import { createMistralModelProvider } from "generative-ts";

    const mistralLarge = createMistralModelProvider({
    modelId: "mistral-large-latest", // Mistral defined model ID
    // you can explicitly pass auth here, otherwise by default it is read from process.env
    });

    const response = await mistralLarge.sendRequest({
    $prompt: "Brief History of NY Mets:"
    // all other Mistral ChatCompletion API options available here
    });

    console.log(response.choices[0]?.message.content);