POST
/
prompts
/
{promptId}
/
render
curl -X POST "https://api.portkey.ai/v1/prompts/YOUR_PROMPT_ID/render" \
  -H "Content-Type: application/json" \
  -H "x-portkey-api-key: $PORTKEY_API_KEY" \
  -d '{
    "variables": {
      "user_input": "Hello world"
    },
    "max_tokens": 250,
    "presence_penalty": 0.2
  }'
{
  "success": true,
  "data": {
    "messages": [
      {
        "content": "<string>",
        "role": "system",
        "name": "<string>"
      }
    ],
    "model": "gpt-4-turbo",
    "frequency_penalty": 0,
    "logit_bias": null,
    "logprobs": false,
    "top_logprobs": 10,
    "max_tokens": 123,
    "n": 1,
    "presence_penalty": 0,
    "response_format": {
      "type": "text"
    },
    "seed": 0,
    "stop": "<string>",
    "stream": false,
    "stream_options": null,
    "temperature": 1,
    "top_p": 1,
    "tools": [
      {
        "type": "function",
        "function": {
          "description": "<string>",
          "name": "<string>",
          "parameters": {}
        }
      }
    ],
    "tool_choice": "none",
    "parallel_tool_calls": true,
    "user": "user-1234",
    "function_call": "none",
    "functions": [
      {
        "description": "<string>",
        "name": "<string>",
        "parameters": {}
      }
    ]
  }
}

Given a prompt ID, variable values, and optionally any hyperparameters, this API returns a JSON object containing the raw prompt template.

Note: Unlike inference requests, Prompt Render API calls are processed through Portkey’s Control Plane services.

Authorizations

x-portkey-api-key
string
header
required

Path Parameters

promptId
string
required

The unique identifier of the prompt template to render

Body

application/json

Note: Although hyperparameters are shown grouped here (like messages, max_tokens, temperature, etc.), they should only be passed at the root level, alongside 'variables' and 'stream'.

variables
object
required

Variables to substitute in the prompt template

hyperparameters
object

Note: All hyperparameters are optional. Pass them at the root level, and not nested under hyperparameters. Their grouping here is for educational purposes only.

Response

200 - application/json
Successful rendered prompt
success
boolean
required

Indicates if the render was successful

data
object
required