Our Python SDK got smarter. We developed a Typscript SDK too. We are updating our SDK code blocks. Python SDKhere.Typscript SDKhere.
Description

Create Prompt Revision

Create a new prompt revision.

If prompt_id is provided, creates a new revision of an existing prompt definition.

If prompt_id is not provided but prompt_name is, creates a new prompt definition with its first revision.

Either project_id or project_name must be provided.

If project_name is provided and doesn't exist, a new project will be created.

Returns the newly created prompt revision.

POST
/v1/prompt-revisions
/v1/prompt-revisions

The Authorization access token

Authorization

X-API-KEY<token>

In: header

Request Body

application/jsonRequired

project_idProject Id

project_nameProject Name

prompt_idPrompt Id

prompt_namePrompt Name

prompt_descriptionPrompt Description

create_only_if_not_existsCreate Only If Not Exists

If true, creation will fail if a prompt with the same name already exists in the project. Only applies when creating a new prompt (not providing prompt_id).

Default: false

body
Required
Body

Maximum length: 500000

metadataMetadata

Optional JSON metadata to associate with this revision

curl -X POST "https://api.patronus.ai/v1/prompt-revisions" \
  -H "X-API-KEY: <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
    "project_name": "string",
    "prompt_id": "24783230-27c2-455c-9de9-95bbdbb78c3d",
    "prompt_name": "string",
    "prompt_description": "string",
    "create_only_if_not_exists": false,
    "body": "string",
    "metadata": {}
  }'

Successful Response

{
  "prompt_revision": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "prompt_definition_id": "03a177e8-e6c3-4579-9b5a-f1a28527d534",
    "prompt_definition_name": "string",
    "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
    "project_name": "string",
    "revision": 0,
    "body": "string",
    "normalized_body_sha256": "string",
    "metadata": {},
    "labels": [
      "string"
    ],
    "created_at": "2019-08-24T14:15:22Z"
  }
}