Skip to content

Latest commit

 

History

History
942 lines (693 loc) · 72 KB

File metadata and controls

942 lines (693 loc) · 72 KB

Beta.Agents

Overview

(beta) Agents API

Available Operations

create

Create a new agent giving it instructions, tools, description. The agent is then available to be used as a regular assistant in a conversation or as part of an agent pool from which it can be used.

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.agents.create({
    completionArgs: {
      responseFormat: {
        type: "text",
      },
    },
    model: "LeBaron",
    name: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsCreate } from "@mistralai/mistralai/funcs/betaAgentsCreate.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 betaAgentsCreate(mistral, {
    completionArgs: {
      responseFormat: {
        type: "text",
      },
    },
    model: "LeBaron",
    name: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsCreate failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

list

Retrieve a list of agent entities sorted by creation time. Deprecated: some features such as agent sharing are not supported by this endpoint. Use the cursor-paginated GET /v1/agents/pages instead.

⚠️ DEPRECATED: Some features such as agent sharing are not supported by this endpoint.. Use listPages instead.

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.agents.list({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsList } from "@mistralai/mistralai/funcs/betaAgentsList.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 betaAgentsList(mistral, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.AgentsApiV1AgentsListRequest ✔️ 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.Agent[]>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

listPages

Retrieve a page of agent entities. Unlike the deprecated GET /v1/agents, this endpoint paginates by opaque cursor and honors per-agent sharing, returning only agents the caller is authorized to see.

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.agents.listPages({});

  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 { betaAgentsListPages } from "@mistralai/mistralai/funcs/betaAgentsListPages.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 betaAgentsListPages(mistral, {});
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("betaAgentsListPages failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get

Given an agent, retrieve an agent entity with its attributes. The agent_version parameter can be an integer version number or a string alias.

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.agents.get({
    agentId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsGet } from "@mistralai/mistralai/funcs/betaAgentsGet.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 betaAgentsGet(mistral, {
    agentId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsGet failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

update

Update an agent attributes and create a new version.

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.agents.update({
    agentId: "<id>",
    updateAgentRequest: {
      completionArgs: {
        responseFormat: {
          type: "text",
        },
      },
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsUpdate } from "@mistralai/mistralai/funcs/betaAgentsUpdate.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 betaAgentsUpdate(mistral, {
    agentId: "<id>",
    updateAgentRequest: {
      completionArgs: {
        responseFormat: {
          type: "text",
        },
      },
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsUpdate failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

delete

Delete an agent entity.

Example Usage

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

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

async function run() {
  await mistral.beta.agents.delete({
    agentId: "<id>",
  });


}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsDelete } from "@mistralai/mistralai/funcs/betaAgentsDelete.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 betaAgentsDelete(mistral, {
    agentId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("betaAgentsDelete failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

updateVersion

Switch the version of an agent.

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.agents.updateVersion({
    agentId: "<id>",
    version: 157995,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsUpdateVersion } from "@mistralai/mistralai/funcs/betaAgentsUpdateVersion.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 betaAgentsUpdateVersion(mistral, {
    agentId: "<id>",
    version: 157995,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsUpdateVersion failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

listVersions

Retrieve all versions for a specific agent with full agent context. Supports pagination.

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.agents.listVersions({
    agentId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsListVersions } from "@mistralai/mistralai/funcs/betaAgentsListVersions.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 betaAgentsListVersions(mistral, {
    agentId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsListVersions failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.AgentsApiV1AgentsListVersionsRequest ✔️ 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.Agent[]>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

getVersion

Get a specific agent version by version number.

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.agents.getVersion({
    agentId: "<id>",
    version: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsGetVersion } from "@mistralai/mistralai/funcs/betaAgentsGetVersion.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 betaAgentsGetVersion(mistral, {
    agentId: "<id>",
    version: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsGetVersion failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

createVersionAlias

Create a new alias or update an existing alias to point to a specific version. Aliases are unique per agent and can be reassigned to different versions.

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.agents.createVersionAlias({
    agentId: "<id>",
    alias: "<value>",
    version: 595141,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsCreateVersionAlias } from "@mistralai/mistralai/funcs/betaAgentsCreateVersionAlias.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 betaAgentsCreateVersionAlias(mistral, {
    agentId: "<id>",
    alias: "<value>",
    version: 595141,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsCreateVersionAlias failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

listVersionAliases

Retrieve all version aliases for a specific agent.

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.agents.listVersionAliases({
    agentId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsListVersionAliases } from "@mistralai/mistralai/funcs/betaAgentsListVersionAliases.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 betaAgentsListVersionAliases(mistral, {
    agentId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("betaAgentsListVersionAliases failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.AgentsApiV1AgentsListVersionAliasesRequest ✔️ 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.AgentAliasResponse[]>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

deleteVersionAlias

Delete an existing alias for an agent.

Example Usage

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

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

async function run() {
  await mistral.beta.agents.deleteVersionAlias({
    agentId: "<id>",
    alias: "<value>",
  });


}

run();

Standalone function

The standalone function version of this method:

import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaAgentsDeleteVersionAlias } from "@mistralai/mistralai/funcs/betaAgentsDeleteVersionAlias.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 betaAgentsDeleteVersionAlias(mistral, {
    agentId: "<id>",
    alias: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("betaAgentsDeleteVersionAlias failed:", res.error);
  }
}

run();

Parameters

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

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*