Skip to content

Latest commit

 

History

History
319 lines (224 loc) · 22.4 KB

README.md

File metadata and controls

319 lines (224 loc) · 22.4 KB

MistralJobs

(batch.jobs)

Overview

Available Operations

  • list - Get Batch Jobs
  • create - Create Batch Job
  • get - Get Batch Job
  • cancel - Cancel Batch Job

list

Get a list of batch jobs for your organization and user.

Example Usage

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

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

async function run() {
  const result = await mistral.batch.jobs.list();

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { batchJobsList } from "@mistralai/mistralai/funcs/batchJobsList.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 batchJobsList(mistral);

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.JobsApiRoutesBatchGetBatchJobsRequest ✔️ 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.BatchJobsOut>

Errors

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

create

Create a new batch job, it will be queued for processing.

Example Usage

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

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

async function run() {
  const result = await mistral.batch.jobs.create({
    inputFiles: [
      "a621cf02-1cd9-4cf5-8403-315211a509a3",
    ],
    endpoint: "/v1/fim/completions",
    model: "2",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { batchJobsCreate } from "@mistralai/mistralai/funcs/batchJobsCreate.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 batchJobsCreate(mistral, {
    inputFiles: [
      "a621cf02-1cd9-4cf5-8403-315211a509a3",
    ],
    endpoint: "/v1/fim/completions",
    model: "2",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request components.BatchJobIn ✔️ 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.BatchJobOut>

Errors

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

get

Get a batch job details by its UUID.

Example Usage

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

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

async function run() {
  const result = await mistral.batch.jobs.get({
    jobId: "b888f774-3e7c-4135-a18c-6b985523c4bc",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { batchJobsGet } from "@mistralai/mistralai/funcs/batchJobsGet.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 batchJobsGet(mistral, {
    jobId: "b888f774-3e7c-4135-a18c-6b985523c4bc",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.JobsApiRoutesBatchGetBatchJobRequest ✔️ 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.BatchJobOut>

Errors

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

cancel

Request the cancellation of a batch job.

Example Usage

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

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

async function run() {
  const result = await mistral.batch.jobs.cancel({
    jobId: "0f713502-9233-41c6-9ebd-c570b7edb496",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { batchJobsCancel } from "@mistralai/mistralai/funcs/batchJobsCancel.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 batchJobsCancel(mistral, {
    jobId: "0f713502-9233-41c6-9ebd-c570b7edb496",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.JobsApiRoutesBatchCancelBatchJobRequest ✔️ 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.BatchJobOut>

Errors

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