Branches
Overview
The Confident AI SDK exposes every Branch 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 Branches
Lists the branches of the prompt.
from confident_ai import ConfidentAI
client = ConfidentAI()
prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.list_branches()For async mode, call a_list_branches and await it as shown below:
result = await prompt.a_list_branches(...)import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const prompt = client.prompt("<PROMPT-ID>");
const result = await prompt.listBranches();Returns
This method returns an object of type PromptBranchList.
Create Branch
Creates a branch of the prompt diverging from the head commit of main.
from confident_ai import ConfidentAI
client = ConfidentAI()
prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.create_branch(name="experiment")For async mode, call a_create_branch and await it as shown below:
result = await prompt.a_create_branch(...)Parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Required. The name of the branch to create. It diverges from the head commit of main. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const prompt = client.prompt("<PROMPT-ID>");
const result = await prompt.createBranch("experiment");Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Required. The name of the branch to create. It diverges from the head commit of main. |
Returns
This method returns an object of type PromptBranch.
Update Branch
Renames a branch of the prompt. The main branch cannot be renamed.
from confident_ai import ConfidentAI
client = ConfidentAI()
prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.update_branch(branch_id="<BRANCH-ID>", name="experiment-v2")For async mode, call a_update_branch and await it as shown below:
result = await prompt.a_update_branch(...)Parameters
| Parameter | Type | Description |
|---|---|---|
branch_id | str | Required. The unique id of the branch. |
name | str | Required. The new name of the branch. The main branch cannot be renamed. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const prompt = client.prompt("<PROMPT-ID>");
const result = await prompt.updateBranch("<BRANCH-ID>", "experiment-v2");Parameters
| Parameter | Type | Description |
|---|---|---|
branchId | string | Required. The unique id of the branch. |
name | string | Required. The new name of the branch. The main branch cannot be renamed. |
Returns
This method returns an object of type PromptBranchRef.
Delete Branch
Deletes a branch of the prompt. The main branch, branches with open pull requests, and branches referenced by AI connections cannot be deleted.
from confident_ai import ConfidentAI
client = ConfidentAI()
prompt = client.prompt(prompt_id="<PROMPT-ID>")
result = prompt.delete_branch(branch_id="<BRANCH-ID>")For async mode, call a_delete_branch and await it as shown below:
result = await prompt.a_delete_branch(...)Parameters
| Parameter | Type | Description |
|---|---|---|
branch_id | str | Required. The unique id of the branch. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const prompt = client.prompt("<PROMPT-ID>");
const result = await prompt.deleteBranch("<BRANCH-ID>");Parameters
| Parameter | Type | Description |
|---|---|---|
branchId | string | Required. The unique id of the branch. |
Returns
This method returns an object of type PromptBranchRef.
Methods (Stateless)
These methods take every argument themselves, so a caller reaches them through client.prompts without opening a Prompt first.
Get Branches
Lists the branches of the prompt.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.get_branches(prompt_id="<PROMPT-ID>")For async mode, call a_get_branches and await it as shown below:
result = await client.prompts.a_get_branches(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.getBranches("<PROMPT-ID>");Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
Returns
This method returns an object of type PromptBranchList.
Create Branch
Creates a branch of the prompt diverging from the head commit of main.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.create_branch(
prompt_id="<PROMPT-ID>",
name="experiment",
)For async mode, call a_create_branch and await it as shown below:
result = await client.prompts.a_create_branch(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
name | str | Required. The name of the branch to create. It diverges from the head commit of main. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.createBranch(
"<PROMPT-ID>",
"experiment",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
name | string | Required. The name of the branch to create. It diverges from the head commit of main. |
Returns
This method returns an object of type PromptBranch.
Update Branch
Renames a branch of the prompt. The main branch cannot be renamed.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.update_branch(
prompt_id="<PROMPT-ID>",
branch_id="<BRANCH-ID>",
name="experiment-v2",
)For async mode, call a_update_branch and await it as shown below:
result = await client.prompts.a_update_branch(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
branch_id | str | Required. The unique id of the branch. |
name | str | Required. The new name of the branch. The main branch cannot be renamed. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.updateBranch(
"<PROMPT-ID>",
"<BRANCH-ID>",
"experiment-v2",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
branchId | string | Required. The unique id of the branch. |
name | string | Required. The new name of the branch. The main branch cannot be renamed. |
Returns
This method returns an object of type PromptBranchRef.
Delete Branch
Deletes a branch of the prompt. The main branch, branches with open pull requests, and branches referenced by AI connections cannot be deleted.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.delete_branch(
prompt_id="<PROMPT-ID>",
branch_id="<BRANCH-ID>",
)For async mode, call a_delete_branch and await it as shown below:
result = await client.prompts.a_delete_branch(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
branch_id | str | Required. The unique id of the branch. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.deleteBranch(
"<PROMPT-ID>",
"<BRANCH-ID>",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
branchId | string | Required. The unique id of the branch. |
Returns
This method returns an object of type PromptBranchRef.
Types
PromptBranch
class PromptBranch:
id: str
name: stridstrRequired
This is the unique id of the prompt branch.
Example: "<BRANCH-ID>"
namestrRequired
This is the name of the prompt branch.
Example: "experiment"
interface PromptBranch {
id: string;
name: string;
}idstringRequired
This is the unique id of the prompt branch.
Example: "<BRANCH-ID>"
namestringRequired
This is the name of the prompt branch.
Example: "experiment"
PromptBranchList
class PromptBranchList:
branches: List[PromptBranch]branchesList[PromptBranch]Required
This is the list of branches on the prompt.
See PromptBranch.
interface PromptBranchList {
branches: PromptBranch[];
}branchesPromptBranch[]Required
This is the list of branches on the prompt.
See PromptBranch.
PromptBranchRef
class PromptBranchRef:
id: stridstrRequired
This is the unique id of the prompt branch.
Example: "<BRANCH-ID>"
interface PromptBranchRef {
id: string;
}idstringRequired
This is the unique id of the prompt branch.
Example: "<BRANCH-ID>"
Last updated on