Skip to main content

Methods

Get a prompt by its ID.

Parameters

id
str
required

Returns

GetPromptResponse
GetPromptResponse
🔗 GetPromptResponseThe prompt data

Usage

from truefoundry import TrueFoundry

client = TrueFoundry(
    api_key="YOUR_API_KEY",
    base_url="https://yourhost.com/path/to/api",
)

client.prompts.get(
    id="id_value",
)
Delete a prompt by its ID.

Parameters

id
str
required

Returns

EmptyResponse
EmptyResponse
🔗 EmptyResponseEmpty response indicating successful deletion

Usage

from truefoundry import TrueFoundry

client = TrueFoundry(
    api_key="YOUR_API_KEY",
    base_url="https://yourhost.com/path/to/api",
)

client.prompts.delete(
    id="id_value",
)
List prompts with optional filtering by FQN, ML Repo, or name.

Parameters

fqn
typing.Optional[str]
Fully qualified name to filter prompts by (format: ‘chat_prompt://’)
ml_repo_id
typing.Optional[str]
ID of the ML Repo to filter prompts by
name
typing.Optional[str]
Name of the prompt to filter by
offset
typing.Optional[int]
Number of prompts to skip for pagination
limit
typing.Optional[int]
Maximum number of prompts to return
include_empty_prompts
typing.Optional[bool]
Whether to include prompts that have no versions

Returns

SyncPager[Prompt, ListPromptsResponse]
SyncPager[Prompt, ListPromptsResponse]
🔗 ListPromptsResponseList of prompts matching the query with pagination information

Usage

from truefoundry import TrueFoundry

client = TrueFoundry(
    api_key="YOUR_API_KEY",
    base_url="https://yourhost.com/path/to/api",
)

client.prompts.list(
    fqn="value",
    ml_repo_id="value",
    name="value",
    offset=10,
    limit=10,
    include_empty_prompts="value",
)

# Iterate through results
for item in response:
    print(item.name)

# Or paginate page by page
for page in response.iter_pages():
    for item in page:
        print(item.name)
Create or update a prompt version.

Parameters

manifest
ChatPromptManifest
required
🔗 ChatPromptManifestManifest containing metadata for the prompt to apply

Returns

GetPromptVersionResponse
GetPromptVersionResponse
🔗 GetPromptVersionResponseThe created or updated prompt version

Usage

from truefoundry import TrueFoundry

client = TrueFoundry(
    api_key="YOUR_API_KEY",
    base_url="https://yourhost.com/path/to/api",
)

client.prompts.create_or_update(
    manifest={"key": "value"},
)
Get Prompt by FQN.

Parameters

fqn
str
required
FQN of the prompt

Returns

GetPromptResponse
GetPromptResponse

Usage

from truefoundry import TrueFoundry

client = TrueFoundry(
    api_key="YOUR_API_KEY",
    base_url="https://yourhost.com/path/to/api",
)

client.prompts.get_by_fqn(
    fqn="value",
)