Skip to content

Latest commit

Β 

History

History
404 lines (265 loc) Β· 30.2 KB

File metadata and controls

404 lines (265 loc) Β· 30.2 KB

Beta.Prompts

Overview

Available Operations

list

ListPrompts

Example Usage

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()

Parameters

Parameter Type Required Description
page_size Optional[int] βž– N/A
page_token Optional[str] βž– N/A
alias Optional[str] βž– N/A
fields List[str] βž– N/A
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.PromptsListResponse

Errors

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

create

CreatePrompt

Example Usage

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)

Parameters

Parameter Type Required Description
name str βœ”οΈ Stable object name.
definition models.PromptDefinition βœ”οΈ Versioned prompt content.
title OptionalNullable[str] βž– Display title.
description OptionalNullable[str] βž– Display description.
notes OptionalNullable[str] βž– Notes for this version.
sharing_scope Optional[models.RegistrySharingScope] βž– N/A
aliases List[str] βž– Aliases pointing to this version.
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.Prompt

Errors

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

get

GetPrompt

Example Usage

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)

Parameters

Parameter Type Required Description Example
prompt_id str βœ”οΈ N/A
version Optional[int] βž– N/A 1
alias Optional[str] βž– N/A
fields List[str] βž– N/A
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.Prompt

Errors

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

delete

DeletePrompt

Example Usage

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)

Parameters

Parameter Type Required Description
prompt_id str βœ”οΈ N/A
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.DeletePromptResponse

Errors

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

update_metadata

UpdatePrompt

Example Usage

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)

Parameters

Parameter Type Required Description
prompt_id str βœ”οΈ N/A
title OptionalNullable[str] βž– Display title.
description OptionalNullable[str] βž– Display description.
sharing_scope Optional[models.RegistrySharingScope] βž– N/A
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.Prompt

Errors

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

list_versions

ListPromptVersions

Example Usage

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)

Parameters

Parameter Type Required Description
prompt_id str βœ”οΈ N/A
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.ListPromptVersionsResponse

Errors

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

create_version

CreatePromptVersion

Example Usage

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)

Parameters

Parameter Type Required Description
prompt_id str βœ”οΈ N/A
definition models.PromptDefinition βœ”οΈ Versioned prompt content.
notes OptionalNullable[str] βž– Notes for this version.
aliases List[str] βž– Aliases pointing to this version.
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.CreatePromptVersionResponse

Errors

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

get_version

GetPromptVersion

Example Usage

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)

Parameters

Parameter Type Required Description Example
prompt_id str βœ”οΈ N/A
version int βœ”οΈ N/A 1
fields List[str] βž– N/A
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.Prompt

Errors

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

update_version_metadata

UpdatePromptVersionMetadata

Example Usage

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)

Parameters

Parameter Type Required Description Example
prompt_id str βœ”οΈ N/A
version int βœ”οΈ N/A 1
notes OptionalNullable[str] βž– Notes for this version.
aliases Optional[models.AliasList] βž– Presence wrapper for a set of alias labels on update RPCs. As a message field it carries presence, so callers can distinguish "leave aliases unchanged" (field omitted) from "clear all aliases" (field set, empty values).
retries Optional[utils.RetryConfig] βž– Configuration to override the default retry behavior of the client.

Response

models.Prompt

Errors

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