Tree BG 1
Tree
Tree
TreeLeaves
TreeLeaves
Cat IdleGrassGrassRockRock

Beta Prompts Endpoints

(beta) Prompts API.

ListPrompts

GET /v2/prompts#

ListPrompts

200

Success

nextPageToken#
string

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

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

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.list()

    while res is not None:
        # Handle items

        res = res.next()

curl https://api.mistral.ai/v2/prompts \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "data": [
    {
      "id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
      "name": "support-answer-style",
      "definition": {
        "content": "Write a concise support answer for {{customer_name}} about {{issue}}.",
        "variables": [
          {
            "name": "customer_name"
          },
          {
            "name": "issue"
          }
        ]
      },
      "version": 1,
      "notes": "Initial prompt version.",
      "aliases": [
        "production"
      ],
      "sharingScope": "workspace",
      "createdAt": "2025-01-15T09:30:00Z",
      "updatedAt": "2025-01-15T10:00:00Z",
      "latestVersion": 1,
      "title": "Support answer style",
      "description": "Prompt used by the support assistant."
    }
  ],
  "nextPageToken": "eyJwYWdlIjoyfQ=="
}

CreatePrompt

POST /v2/prompts#

CreatePrompt

200

Success

aliases#
array<string>

Aliases pointing to this version.

createdAt#
date-time

RFC 3339 timestamp.

Versioned prompt content.

description#
string

Display description.

id#
string
latestVersion#
int32

Latest version number.

name#
string

Stable object name.

notes#
string

Notes for this version.

sharingScope#
"sharing_scope_unspecified"|"private"|"workspace"
title#
string

Display title.

updatedAt#
date-time

RFC 3339 timestamp.

version#
int32

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.create(name="<value>", definition={
        "content": "<value>",
    })

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts \
 -X POST \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -H 'Content-Type: application/json' \
 -d '{
  "definition": {
    "content": "Example content."
  },
  "name": "My resource"
}'

200

{
  "id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
  "name": "support-answer-style",
  "definition": {
    "content": "Write a concise support answer for {{customer_name}} about {{issue}}.",
    "variables": [
      {
        "name": "customer_name"
      },
      {
        "name": "issue"
      }
    ]
  },
  "version": 1,
  "notes": "Initial prompt version.",
  "aliases": [
    "production"
  ],
  "sharingScope": "workspace",
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T10:00:00Z",
  "latestVersion": 1,
  "title": "Support answer style",
  "description": "Prompt used by the support assistant."
}

GetPrompt

GET /v2/prompts/{prompt_id}#

GetPrompt

200

Success

aliases#
array<string>

Aliases pointing to this version.

createdAt#
date-time

RFC 3339 timestamp.

Versioned prompt content.

description#
string

Display description.

id#
string
latestVersion#
int32

Latest version number.

name#
string

Stable object name.

notes#
string

Notes for this version.

sharingScope#
"sharing_scope_unspecified"|"private"|"workspace"
title#
string

Display title.

updatedAt#
date-time

RFC 3339 timestamp.

version#
int32

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.get(prompt_id="<id>", version=1)

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts/{prompt_id} \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
  "name": "support-answer-style",
  "definition": {
    "content": "Write a concise support answer for {{customer_name}} about {{issue}}.",
    "variables": [
      {
        "name": "customer_name"
      },
      {
        "name": "issue"
      }
    ]
  },
  "version": 1,
  "notes": "Initial prompt version.",
  "aliases": [
    "production"
  ],
  "sharingScope": "workspace",
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T10:00:00Z",
  "latestVersion": 1,
  "title": "Support answer style",
  "description": "Prompt used by the support assistant."
}

DeletePrompt

DELETE /v2/prompts/{prompt_id}#

DeletePrompt

200

Success

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.delete(prompt_id="<id>")

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts/{prompt_id} \
 -X DELETE \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -H 'Content-Type: application/json'

200

{}

UpdatePrompt

PATCH /v2/prompts/{prompt_id}#

UpdatePrompt

200

Success

aliases#
array<string>

Aliases pointing to this version.

createdAt#
date-time

RFC 3339 timestamp.

Versioned prompt content.

description#
string

Display description.

id#
string
latestVersion#
int32

Latest version number.

name#
string

Stable object name.

notes#
string

Notes for this version.

sharingScope#
"sharing_scope_unspecified"|"private"|"workspace"
title#
string

Display title.

updatedAt#
date-time

RFC 3339 timestamp.

version#
int32

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.update_metadata(prompt_id="<id>")

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts/{prompt_id} \
 -X PATCH \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -H 'Content-Type: application/json' \
 -d '{}'

200

{
  "id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
  "name": "support-answer-style",
  "definition": {
    "content": "Write a concise support answer for {{customer_name}} about {{issue}}.",
    "variables": [
      {
        "name": "customer_name"
      },
      {
        "name": "issue"
      }
    ]
  },
  "version": 1,
  "notes": "Initial prompt version.",
  "aliases": [
    "production"
  ],
  "sharingScope": "workspace",
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T10:00:00Z",
  "latestVersion": 1,
  "title": "Support answer style",
  "description": "Prompt used by the support assistant."
}

ListPromptVersions

GET /v2/prompts/{prompt_id}/versions#

ListPromptVersions

200

Success

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.list_versions(prompt_id="<id>")

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts/{prompt_id}/versions \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "data": [
    {
      "version": 1,
      "definition": {
        "content": "Write a concise support answer for {{customer_name}} about {{issue}}.",
        "variables": [
          {
            "name": "customer_name"
          },
          {
            "name": "issue"
          }
        ]
      },
      "notes": "Initial prompt version.",
      "aliases": [
        "production"
      ],
      "createdAt": "2025-01-15T09:30:00Z"
    }
  ]
}

CreatePromptVersion

POST /v2/prompts/{prompt_id}/versions#

CreatePromptVersion

200

Success

deduplicated#
boolean
version#
int32

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.create_version(prompt_id="<id>", definition={
        "content": "<value>",
    })

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts/{prompt_id}/versions \
 -X POST \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -H 'Content-Type: application/json' \
 -d '{
  "definition": {
    "content": "Example content."
  }
}'

200

{
  "version": 2,
  "deduplicated": false
}

GetPromptVersion

GET /v2/prompts/{prompt_id}/versions/{version}#

GetPromptVersion

200

Success

aliases#
array<string>

Aliases pointing to this version.

createdAt#
date-time

RFC 3339 timestamp.

Versioned prompt content.

description#
string

Display description.

id#
string
latestVersion#
int32

Latest version number.

name#
string

Stable object name.

notes#
string

Notes for this version.

sharingScope#
"sharing_scope_unspecified"|"private"|"workspace"
title#
string

Display title.

updatedAt#
date-time

RFC 3339 timestamp.

version#
int32

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.get_version(prompt_id="<id>", version=1)

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts/{prompt_id}/versions/{version} \
 -X GET \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE'

200

{
  "id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
  "name": "support-answer-style",
  "definition": {
    "content": "Write a concise support answer for {{customer_name}} about {{issue}}.",
    "variables": [
      {
        "name": "customer_name"
      },
      {
        "name": "issue"
      }
    ]
  },
  "version": 1,
  "notes": "Initial prompt version.",
  "aliases": [
    "production"
  ],
  "sharingScope": "workspace",
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T10:00:00Z",
  "latestVersion": 1,
  "title": "Support answer style",
  "description": "Prompt used by the support assistant."
}

UpdatePromptVersionMetadata

PATCH /v2/prompts/{prompt_id}/versions/{version}#

UpdatePromptVersionMetadata

200

Success

aliases#
array<string>

Aliases pointing to this version.

createdAt#
date-time

RFC 3339 timestamp.

Versioned prompt content.

description#
string

Display description.

id#
string
latestVersion#
int32

Latest version number.

name#
string

Stable object name.

notes#
string

Notes for this version.

sharingScope#
"sharing_scope_unspecified"|"private"|"workspace"
title#
string

Display title.

updatedAt#
date-time

RFC 3339 timestamp.

version#
int32

Playground

Test the endpoints live

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

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

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

  console.log(result);
}

run();
from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.prompts.update_version_metadata(prompt_id="<id>", version=1)

    # Handle response
    print(res)

curl https://api.mistral.ai/v2/prompts/{prompt_id}/versions/{version} \
 -X PATCH \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -H 'Content-Type: application/json' \
 -d '{}'

200

{
  "id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
  "name": "support-answer-style",
  "definition": {
    "content": "Write a concise support answer for {{customer_name}} about {{issue}}.",
    "variables": [
      {
        "name": "customer_name"
      },
      {
        "name": "issue"
      }
    ]
  },
  "version": 1,
  "notes": "Promote this version after support review.",
  "aliases": [
    "production"
  ],
  "sharingScope": "workspace",
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T10:00:00Z",
  "latestVersion": 1,
  "title": "Support answer style",
  "description": "Prompt used by the support assistant."
}