Launch Week 3: Five days of launches

Versions

Overview

The Confident AI SDK exposes every Version method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.

Methods

List Versions

Lists every version released for the prompt, oldest first.

from confident_ai import ConfidentAI

client = ConfidentAI()

prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.list_versions()

For async mode, call a_list_versions and await it as shown below:

result = await prompt.a_list_versions(...)

Returns

This method returns an object of type PromptVersionList.

Create Version

Releases a commit as a new version of the prompt. Versions the commit with the given hash, or the head commit of main when no hash is given.

from confident_ai import ConfidentAI

client = ConfidentAI()

prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.create_version(hash="bab04ce")

For async mode, call a_create_version and await it as shown below:

result = await prompt.a_create_version(...)

Parameters

ParameterTypeDescription
hashOptional[str]The hash of the commit to release as a new version. Only commits newer than the last versioned commit can be released. When omitted, the head commit of main is versioned.

Returns

This method returns an object of type CreatePromptVersionResult.

Methods (Stateless)

These methods take every argument themselves, so a caller reaches them through client.prompts without opening a Prompt first.

Get Versions

Lists every version released for the prompt, oldest first.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.get_versions(prompt_id="<PROMPT-ID>")

For async mode, call a_get_versions and await it as shown below:

result = await client.prompts.a_get_versions(...)

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.

Returns

This method returns an object of type PromptVersionList.

Create Version

Releases a commit as a new version of the prompt. Versions the commit with the given hash, or the head commit of main when no hash is given.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.prompts.create_version(
    prompt_id="<PROMPT-ID>",
    hash="bab04ce",
)

For async mode, call a_create_version and await it as shown below:

result = await client.prompts.a_create_version(...)

Parameters

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
hashOptional[str]The hash of the commit to release as a new version. Only commits newer than the last versioned commit can be released. When omitted, the head commit of main is versioned.

Returns

This method returns an object of type CreatePromptVersionResult.

Types

CreatePromptVersionResult

class CreatePromptVersionResult:
    version: str
    hash: str

versionstrRequired

The version number generated by Confident AI for the new version. It is always incremental.

Example: "00.00.02"

hashstrRequired

The hash of the commit that was versioned. This is the hash you passed, or the head of main when you omitted it.

Example: "bab04ce"

PromptType

This is the type of the prompt, which can be either a simple text or a list of messages.

class PromptType(Enum):
    TEXT = "TEXT"
    LIST = "LIST"

TEXT · LIST

PromptVersion

class PromptVersion:
    id: str
    version: str

idstrRequired

This is the id of the prompt version generated by Confident AI, not to be confused with the version number.

Example: "<PROMPT-VERSION-ID>"

versionstrRequired

This is the version number of the prompt version.

Example: "00.00.01"

PromptVersionList

class PromptVersionList:
    versions: List[PromptVersion]
    type: PromptType

versionsList[PromptVersion]Required

This is the list of versions released for the prompt, oldest first.

See PromptVersion.

typePromptTypeRequired

Building a production pipeline?Design a scalable API workflow for evals, datasets, traces, and promptsTalk to an engineer

Last updated on

Built byConfident AI