베타 프롬프트 엔드포인트

베타 프롬프트 엔드포인트 (Beta Prompts Endpoints)

(beta) Prompts API입니다. 프롬프트를 버전 단위로 관리하고, 공유 범위·별칭(alias)·메타데이터를 다루는 엔드포인트예요.

출처: 문서

본문

재사용 가능한 프롬프트를 레지스트리처럼 관리하는 베타 API예요. 프롬프트를 만들고, 버전을 쌓으며, 이름·제목·설명·별칭을 갱신하고, 특정 버전을 조회할 수 있답니다. 공유 범위는 private(비공개) 또는 workspace(워크스페이스)예요.

GET /v2/prompts — ListPrompts (프롬프트 목록)

프롬프트 목록을 나열합니다.

응답 필드 (200 Success):

  • data#array<Prompt> — 프롬프트 목록.
  • nextPageToken#string — 다음 페이지 토큰.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

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

run();

Python:

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:

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

응답 예시 (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": "***=="
}

POST /v2/prompts — CreatePrompt (프롬프트 생성)

새 프롬프트를 만듭니다.

요청 본문:

  • name#string (필수) — 안정적인 객체 이름.
  • definition#PromptDefinition (필수) — 버전이 붙는 프롬프트 내용.
  • description#string|null — 표시용 설명.
  • title#string|null — 표시용 제목.
  • notes#string|null — 이 버전의 메모.
  • aliases#array<string> — 이 버전을 가리키는 별칭.
  • sharingScope#"sharing_scope_unspecified"|"private"|"workspace" — 공유 범위.
  • workspaceRelation#"share_relation_unspecified"|"reader"|"writer" — 공유 객체에 대한 주체의 관계.

응답 필드 (200 Success): id, name, definition, version, latestVersion, createdAt, updatedAt, versionCreatedAt, createdBy, description, title, notes, aliases, sharingScope 등 Prompt 필드.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

curl https://api.mistral.ai/v2/prompts \
 -X POST \
 -H 'Authorization: Bearer ***' \
 -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."
}

GET /v2/prompts/{prompt_id} — GetPrompt (프롬프트 조회)

프롬프트를 가져옵니다.

경로/쿼리 파라미터:

  • prompt_id#string (필수)
  • version#int32 — 특정 버전.
  • alias#string — 별칭.
  • fields#array<string> — 반환할 필드.

응답 필드 (200 Success): Prompt 필드 목록.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

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

DELETE /v2/prompts/{prompt_id} — DeletePrompt (프롬프트 삭제)

프롬프트를 삭제합니다.

경로 파라미터:

  • prompt_id#string (필수)

응답 (200 Success): {}

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

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

PATCH /v2/prompts/{prompt_id} — UpdatePrompt (프롬프트 메타데이터 갱신)

프롬프트 메타데이터를 갱신합니다.

경로 파라미터:

  • prompt_id#string (필수)

요청 본문:

  • description#string|null
  • title#string|null
  • sharingScope#"sharing_scope_unspecified"|"private"|"workspace"
  • workspaceRelation#"share_relation_unspecified"|"reader"|"writer"

응답 필드 (200 Success): Prompt 필드 목록.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

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

GET /v2/prompts/{prompt_id}/versions — ListPromptVersions (버전 목록)

프롬프트의 버전 목록을 가져옵니다.

경로 파라미터:

  • prompt_id#string (필수)

응답 필드 (200 Success):

  • data#array<PromptVersion> — 버전 목록.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

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

응답 예시 (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"
    }
  ]
}

POST /v2/prompts/{prompt_id}/versions — CreatePromptVersion (버전 생성)

프롬프트의 새 버전을 만듭니다.

경로 파라미터:

  • prompt_id#string (필수)

요청 본문:

  • definition#PromptDefinition (필수)
  • notes#string|null
  • aliases#array<string>

응답 필드 (200 Success):

  • deduplicated#boolean — 중복 여부(같은 내용이면 새 버전을 안 만들 수 있어요).
  • version#int32 — 새 버전 번호.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

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

응답 예시 (200):

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

GET /v2/prompts/{prompt_id}/versions/{version} — GetPromptVersion (버전 조회)

특정 버전을 가져옵니다.

경로/쿼리 파라미터:

  • prompt_id#string (필수)
  • version#int32 (필수)
  • fields#array<string>

응답 필드 (200 Success): Prompt 필드 목록.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

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

PATCH /v2/prompts/{prompt_id}/versions/{version} — UpdatePromptVersionMetadata (버전 메타데이터 갱신)

프롬프트 버전의 메타데이터(별칭·메모)를 갱신합니다.

경로 파라미터:

  • prompt_id#string (필수), version#int32 (필수)

요청 본문:

  • aliases#AliasList — 별칭 라벨 집합의 presence 래퍼. update RPC에서 "별칭 그대로" vs "모두 지우기"를 구분할 수 있게 해요.
  • notes#string|null

응답 필드 (200 Success): Prompt 필드 목록.

TypeScript:

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

const mistral = new Mistral({
  apiKey: proces...EY"] ?? "",
});

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

  console.log(result);
}

run();

Python:

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:

curl https://api.mistral.ai/v2/prompts/{prompt_id}/versions/{version} \
 -X PATCH \
 -H 'Authorization: Bearer ***' \
 -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."
}

더 알아보기 (Learn more)