Upsert Prompt

Create a Prompt or update it with a new version if it already exists.

Prompts are identified by the ID or their path. The parameters (i.e. the prompt template, temperature, model etc.) determine the versions of the Prompt.

You can provide version_name and version_description to identify and describe your versions. Version names must be unique within a Prompt - attempting to create a version with a name that already exists will result in a 409 Conflict error.

Headers

X-API-KEYstringRequired

Request

This endpoint expects an object.
modelstringRequired

The model instance used, e.g. gpt-4. See supported models

pathstringOptional

Path of the Prompt, including the name. This locates the Prompt in the Humanloop filesystem and is used as as a unique identifier. For example: folder/name or just name.

idstringOptional
ID for an existing Prompt.
endpointenumOptional
The provider model endpoint used.
Allowed values:
templatestring or list of objectsOptional

The template contains the main structure and instructions for the model, including input variables for dynamic values.

For chat models, provide the template as a ChatTemplate (a list of messages), e.g. a system message, followed by a user message with an input variable. For completion models, provide a prompt template as a string.

Input variables should be specified with double curly bracket syntax: {{input_name}}.

template_languageenumOptional
The template language to use for rendering the template.
Allowed values:
providerenumOptional
The company providing the underlying model service.
max_tokensintegerOptionalDefaults to -1

The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt

temperaturedoubleOptionalDefaults to 1
What sampling temperature to use when making a generation. Higher values means the model will be more creative.
top_pdoubleOptionalDefaults to 1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.

stopstring or list of stringsOptional

The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.

presence_penaltydoubleOptionalDefaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.

frequency_penaltydoubleOptionalDefaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.

othermap from strings to anyOptional
Other parameter values to be passed to the provider call.
seedintegerOptional
If specified, model will make a best effort to sample deterministically, but it is not guaranteed.
response_formatobjectOptional

The format of the response. Only {"type": "json_object"} is currently supported for chat.

reasoning_effortenum or integerOptional

Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.

toolslist of objectsOptional
The tool specification that the model can choose to call if Tool calling is supported.
linked_toolslist of stringsOptional
The IDs of the Tools in your organization that the model can choose to call if Tool calling is supported. The default deployed version of that tool is called.
attributesmap from strings to anyOptional
Additional fields to describe the Prompt. Helpful to separate Prompt versions from each other with details on how they were created or used.
version_namestringOptional
Unique name for the Prompt version. Version names must be unique for a given Prompt.
version_descriptionstringOptional
Description of the version, e.g., the changes made in this version.
descriptionstringOptional
Description of the Prompt.
tagslist of stringsOptional
List of tags associated with this prompt.
readmestringOptional
Long description of the Prompt.

Response

Successful Response
pathstring
Path of the Prompt, including the name, which is used as a unique identifier.
idstring
Unique identifier for the Prompt.
modelstring

The model instance used, e.g. gpt-4. See supported models

namestring
Name of the Prompt.
version_idstring
Unique identifier for the specific Prompt Version. If no query params provided, the default deployed Prompt Version is returned.
created_atdatetime
updated_atdatetime
last_used_atdatetime
version_logs_countinteger
The number of logs that have been generated for this Prompt Version
total_logs_countinteger
The number of logs that have been generated across all Prompt Versions
inputslist of objects
Inputs associated to the Prompt. Inputs correspond to any of the variables used within the Prompt template.
directory_idstring or null
ID of the directory that the file is in on Humanloop.
endpointenum or null
The provider model endpoint used.
Allowed values:
templatestring or list of objects or null

The template contains the main structure and instructions for the model, including input variables for dynamic values.

For chat models, provide the template as a ChatTemplate (a list of messages), e.g. a system message, followed by a user message with an input variable. For completion models, provide a prompt template as a string.

Input variables should be specified with double curly bracket syntax: {{input_name}}.

template_languageenum or null
The template language to use for rendering the template.
Allowed values:
providerenum or null
The company providing the underlying model service.
max_tokensinteger or nullDefaults to -1

The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt

temperaturedouble or nullDefaults to 1
What sampling temperature to use when making a generation. Higher values means the model will be more creative.
top_pdouble or nullDefaults to 1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.

stopstring or list of strings or null

The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.

presence_penaltydouble or nullDefaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.

frequency_penaltydouble or nullDefaults to 0

Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.

othermap from strings to any or null
Other parameter values to be passed to the provider call.
seedinteger or null
If specified, model will make a best effort to sample deterministically, but it is not guaranteed.
response_formatobject or null

The format of the response. Only {"type": "json_object"} is currently supported for chat.

reasoning_effortenum or integer or null

Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.

toolslist of objects or null
The tool specification that the model can choose to call if Tool calling is supported.
linked_toolslist of objects or null
The tools linked to your prompt that the model can call.
attributesmap from strings to any or null
Additional fields to describe the Prompt. Helpful to separate Prompt versions from each other with details on how they were created or used.
version_namestring or null
Unique name for the Prompt version. Version names must be unique for a given Prompt.
version_descriptionstring or null
Description of the version, e.g., the changes made in this version.
descriptionstring or null
Description of the Prompt.
tagslist of strings or null
List of tags associated with the file.
readmestring or null
Long description of the file.
schemamap from strings to any or null
The JSON schema for the Prompt.
type"prompt" or nullDefaults to prompt
environmentslist of objects or null
The list of environments the Prompt Version is deployed to.
created_byany or null
The user who created the Prompt.
evaluatorslist of objects or null
Evaluators that have been attached to this Prompt that are used for monitoring logs.
evaluator_aggregateslist of objects or null
Aggregation of Evaluator results for the Prompt Version.
raw_file_contentstring or null
The raw content of the Prompt. Corresponds to the .prompt file.

Errors