Skip to content

Latest commit

 

History

History
682 lines (499 loc) · 55.3 KB

File metadata and controls

682 lines (499 loc) · 55.3 KB

Beta.Prompts

Overview

Available Operations

list

ListPrompts

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.list();

  for await (const page of result) {
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsList } from "@mistralai/mistralai/funcs/betaPromptsList.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsList(mistral);
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("betaPromptsList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.PromptsListRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.PromptsListResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

create

CreatePrompt

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.create({
    name: "<value>",
    definition: {
      content: "<value>",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsCreate } from "@mistralai/mistralai/funcs/betaPromptsCreate.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsCreate(mistral, {
    name: "<value>",
    definition: {
      content: "<value>",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsCreate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.CreatePromptRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.Prompt>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

get

GetPrompt

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.get({
    promptId: "<id>",
    version: 1,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsGet } from "@mistralai/mistralai/funcs/betaPromptsGet.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsGet(mistral, {
    promptId: "<id>",
    version: 1,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.PromptsGetRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.Prompt>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

delete

DeletePrompt

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.delete({
    promptId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsDelete } from "@mistralai/mistralai/funcs/betaPromptsDelete.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsDelete(mistral, {
    promptId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsDelete failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.PromptsDeleteRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.DeletePromptResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

updateMetadata

UpdatePrompt

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.updateMetadata("<id>", {});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsUpdateMetadata } from "@mistralai/mistralai/funcs/betaPromptsUpdateMetadata.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsUpdateMetadata(mistral, "<id>", {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsUpdateMetadata failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
promptId string ✔️ N/A
requestBody operations.UpdatePromptRequest ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.Prompt>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

listVersions

ListPromptVersions

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.listVersions({
    promptId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsListVersions } from "@mistralai/mistralai/funcs/betaPromptsListVersions.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsListVersions(mistral, {
    promptId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsListVersions failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.PromptsListVersionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.ListPromptVersionsResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

createVersion

CreatePromptVersion

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.createVersion("<id>", {
    definition: {
      content: "<value>",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsCreateVersion } from "@mistralai/mistralai/funcs/betaPromptsCreateVersion.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsCreateVersion(mistral, "<id>", {
    definition: {
      content: "<value>",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsCreateVersion failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
promptId string ✔️ N/A
requestBody operations.CreatePromptVersionRequest ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.CreatePromptVersionResponse>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

getVersion

GetPromptVersion

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.getVersion({
    promptId: "<id>",
    version: 1,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsGetVersion } from "@mistralai/mistralai/funcs/betaPromptsGetVersion.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsGetVersion(mistral, {
    promptId: "<id>",
    version: 1,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsGetVersion failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.PromptsGetVersionRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.Prompt>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

updateVersionMetadata

UpdatePromptVersionMetadata

Example Usage

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const result = await mistral.beta.prompts.updateVersionMetadata("<id>", 1, {});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaPromptsUpdateVersionMetadata } from "@mistralai/mistralai/funcs/betaPromptsUpdateVersionMetadata.js";

// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
  apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});

async function run() {
  const res = await betaPromptsUpdateVersionMetadata(mistral, "<id>", 1, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaPromptsUpdateVersionMetadata failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
promptId string ✔️ N/A
version number ✔️ N/A 1
requestBody operations.UpdatePromptVersionRequest ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.Prompt>

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*