enterprise_ai.prompts
Source: sdks/python/src/enterprise_ai/prompts/__init__.py. Back to the Python SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class PromptsClient
/v1/prompts.
Resource
PromptsClient.create
create(name: str, template: str, **extra: Any) -> Any
Publish a prompt version. Creates a prompt, or publishes a new version when the name exists; identical templates and variables are not duplicated (the current version is returned). The name is lowercase letters, digits, ., _, - (1 to 128 characters, 400 invalid_request otherwise). An unbalanced placeholder, an unknown variable type or a placeholder not declared in variables answers 422 template_error. Needs tenant_admin or developer. Audited as prompt.publish.
Route: /v1/prompts (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Name of the prompt: lowercase letters, digits, ., _, -, 1 to 128 characters, starting and ending with a letter or digit. | |
template | str | yes | Template text with {{ variable }} placeholders (at least 1 character). | |
**extra | Any | no | Extra fields merged into the request body. |
Returns: Any. Decoded JSON answer of the operation "Publish a prompt version".
Raises: the typed errors of the transport (Errors).
PromptsClient.list
list(**page: Any) -> Any
List the prompts. Prompts of the tenant in name order with their latest version number, paginated with cursor.
Route: /v1/prompts (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
**page | Any | no | Pagination options passed to the listing: limit (maximum number of items per page) and cursor (the next_cursor of the previous page). Iterating the returned page follows every cursor. |
Returns: Any. Decoded JSON answer of the operation "List the prompts".
Raises: the typed errors of the transport (Errors).
PromptsClient.render
render(name: str, variables: dict[str, Any], version: str | None = None) -> Any
Render a prompt. Fills the template of a version (default: the latest) with the given values and returns text, chars and estimated_tokens (characters divided by 4). Missing required values, wrong types, values outside enum, values over max_length and, with strict, unknown variables answer 422 missing_variables with one entry per problem. 404 not_found for an unknown prompt or version. Nothing is stored.
Route: /v1/prompts/{name}/render (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Name of the prompt. | |
variables | dict[str, Any] | yes | Value of each variable, by name. | |
version | str | None | None | no | Version number to render. Default: the latest. |
Returns: Any. Decoded JSON answer of the operation "Render a prompt".
Raises: the typed errors of the transport (Errors).
PromptsClient.versions
versions(name: str) -> Any
List the versions of a prompt. The prompt and every version, newest first, with template, variables, model hint, digest and author. 404 not_found.
Route: /v1/prompts/{name}/versions (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Name of the prompt. |
Returns: Any. Decoded JSON answer of the operation "List the versions of a prompt".
Raises: the typed errors of the transport (Errors).
Functions
variables
variables(template: str) -> list[str]
Variable names used as {{ name }} in a template.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
template | str | yes | Template text. |
Returns: list[str]. Sorted names without duplicates, dotted paths kept whole.
render
render(template: str, values: dict[str, Any], strict: bool = True) -> str
Render {{ name }} placeholders (dotted paths allowed). Missing values raise when strict.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
template | str | yes | Template text with {{ name }} or {{ user.name }} placeholders. | |
values | dict[str, Any] | yes | Values by name; a dotted path walks nested dicts. | |
strict | bool | True | no | Raise KeyError on a missing value (default True); otherwise the placeholder is kept. |
Returns: str. The rendered text, every value converted with str.
Raises: KeyError.