POST
/
prompt-version
curl --request POST \
  --url https://api.tela.com/prompt-version \
  --header 'Content-Type: application/json' \
  --data '{
  "promptId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "title": "<string>",
  "content": "<string>",
  "markdownContent": "<string>",
  "configuration": {
    "model": "<string>",
    "temperature": 123,
    "type": "chat",
    "structuredOutput": {
      "enabled": true,
      "schema": {}
    }
  },
  "variables": [
    {
      "name": "<string>",
      "type": "file",
      "required": true,
      "description": "<string>",
      "processingOptions": {
        "allowMultimodal": true
      }
    }
  ],
  "promoted": true,
  "draft": true,
  "messages": {
    "role": "user",
    "content": "<string>",
    "index": 123
  }
}'
{
  "id": "<string>",
  "promptId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "title": "<string>",
  "content": "<string>",
  "markdownContent": "<string>",
  "configuration": {
    "model": "<string>",
    "temperature": 123,
    "type": "chat",
    "structuredOutput": {
      "enabled": true,
      "schema": {}
    }
  },
  "variables": [
    {
      "name": "<string>",
      "type": "file",
      "required": true,
      "description": "<string>",
      "processingOptions": {
        "allowMultimodal": true
      }
    }
  ],
  "promoted": true,
  "draft": true,
  "messages": {
    "role": "user",
    "content": "<string>",
    "index": 123
  },
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z"
}

Create a Prompt Version

This endpoint creates a new version of a prompt with the specified configuration, variables, and content.

Request Body

The request body must include the following fields:

ParameterTypeDescription
promptIdstring (UUID)The ID of the prompt to create a version for
titlestringThe title of the prompt version (max 256 characters)
configurationobjectConfiguration settings for the prompt version
variablesarrayAn array of variable objects used in the prompt

Optional Fields

ParameterTypeDescription
contentstringPlain text content of the prompt
markdownContentstringMarkdown content of the prompt
promotedbooleanWhether this version is promoted
draftbooleanWhether this version is a draft
messagesarray/objectMessages for chat-type prompts

Examples


const promptVersion = {
  promptId: 'prompt_uuid',
  title: 'Document Analysis v2',
  configuration: {
    model: 'claude-3-opus-20240229',
    temperature: 0.7,
    type: 'chat'
  },
  variables: [
    {
      name: 'document',
      type: 'file',
      required: true,
      description: 'The document to analyze'
    },
    {
      name: 'query',
      type: 'text',
      required: true,
      description: 'The specific question about the document'
    }
  ],
  markdownContent: '# Document Analysis\n\nAnalyze the document and answer questions about it.',
  draft: true
}

const response = await fetch('https://api.tela.ai/prompt-version', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.TELA_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(promptVersion)
})

const result = await response.json()
console.log(result)

Response

The response includes the created prompt version object with its assigned ID and other details.

{
  "id": "version_uuid",
  "promptId": "prompt_uuid",
  "title": "Document Analysis v2",
  "markdownContent": "# Document Analysis\n\nAnalyze the document and answer questions about it.",
  "configuration": {
    "model": "claude-3-opus-20240229",
    "temperature": 0.7,
    "type": "chat"
  },
  "variables": [
    {
      "name": "document",
      "type": "file",
      "required": true,
      "description": "The document to analyze"
    },
    {
      "name": "query",
      "type": "text",
      "required": true,
      "description": "The specific question about the document"
    }
  ],
  "draft": true,
  "promoted": false,
  "createdAt": "2024-04-15T12:00:00.000Z",
  "updatedAt": "2024-04-15T12:00:00.000Z"
}

Structured Output Example

const promptVersionWithStructuredOutput = {
  promptId: 'prompt_uuid',
  title: 'Document Analysis with Structured Output',
  configuration: {
    model: 'claude-3-opus-20240229',
    temperature: 0.7,
    type: 'chat',
    structuredOutput: {
      enabled: true,
      schema: {
        type: "object",
        title: "DocumentAnalysis",
        description: "Analysis of a document",
        properties: {
          summary: {
            type: "string",
            description: "Brief summary of the document"
          },
          keyInsights: {
            type: "array",
            items: {
              type: "string"
            },
            description: "Key insights from the document"
          },
          sentiment: {
            type: "string",
            enum: ["positive", "neutral", "negative"],
            description: "Overall sentiment of the document"
          }
        },
        required: ["summary", "keyInsights", "sentiment"]
      }
    }
  },
  variables: [
    {
      name: 'document',
      type: 'file',
      required: true,
      description: 'The document to analyze'
    }
  ]
}

const response = await fetch('https://api.tela.ai/prompt-version', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.TELA_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(promptVersionWithStructuredOutput)
})

const result = await response.json()
console.log(result)

Body

application/json
promptId
string
required

UUID of the prompt to create a version for

title
string
required

Title of the prompt version

Maximum length: 256
configuration
object
required

Configuration settings for the prompt version

variables
object[]
required

Array of variables used in the prompt

content
string | null

Plain text content of the prompt version

markdownContent
string | null

Markdown content of the prompt version

promoted
boolean | null

Whether this version is promoted

draft
boolean | null

Whether this version is a draft

messages

Messages for chat-type prompts

Response

200 - application/json
Prompt version created successfully
id
string
required

Unique identifier for the prompt version

promptId
string
required

UUID of the prompt this version belongs to

title
string
required

Title of the prompt version

Maximum length: 256
configuration
object
required

Configuration settings for the prompt version

variables
object[]
required

Array of variables used in the prompt

content
string | null

Plain text content of the prompt version

markdownContent
string | null

Markdown content of the prompt version

promoted
boolean | null

Whether this version is promoted

draft
boolean | null

Whether this version is a draft

messages

Messages for chat-type prompts

createdAt
string

Creation timestamp

updatedAt
string

Last update timestamp