Skip to main content
/generate

Invoke a prompt and get the generated result.

Promptitude Team avatar
Written by Promptitude Team
Updated over 9 months ago

Endpoint

Simple send a POST request to the endpoint, including the Authorization Header and the Request Object.

Action

POST

Endpoint URL

Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Body

The below Request Object (JSON)

Request Object

Here's an example of the request object for a prompt with two input variables:

{ 
"prompt": {
"promptId": "65a6sdf56f7asd6a7ssdasds",
"inputs": {
"variable1": "value1",
"variable2": "value2"
}
}
"endUserId": "raeyBqUgKtPXDDt0psFrREVjF902",
}

Attributes of the Request Object:


prompt object - required
โ€‹
Sets which prompt to generate and the values of the prompt's input variables.

promptId string - required
The ID of the prompt, as shown at the top of the prompt's detail page.

inputs hash
Set of key-value pairs of all the prompt's input variables.


endUserId string
โ€‹
Optional: A unique identifier of the final end-user who made the call.
Could be a hash of their UID or email address, so it's not identifiable.


Result Object

Here's an example of a result object after invoking a prompt:

{ 
"code": 200,
"message": "OK",
"error": false,
"results": {
"result": "Why did the developer need glasses? Because he couldn't C#!",
"logId": "Z2gV2otfCKIt17t76KFJ",
}
}

Attributes of the Result Object:


code number
Response code. 200 if everything went OK, otherwise the HTTP response code.


message string
"OK" if everything went well. If not, contains the detailed error message.


error boolean
Shows if an error occurred during the request.


results object
Detailed results of the invocation of the prompt.

result string | array | JSON
Final generated output of the prompt, according to the Result Type.

logId string
Unique ID of this invocation. Use in /rate endpoint to add a star rating.


Did this answer your question?