> ## Documentation Index
> Fetch the complete documentation index at: https://docs.promptlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tracking Templates

PromptLayer allows you to track prompt template usage, latency, cost, and more. This is done by associating a request with a prompt template as shown below.

The association appears on the [request log](https://docs.promptlayer.com/features/observability/request-logs.md). Return to [Configure Request Logging](https://docs.promptlayer.com/features/observability/request-logs.md) for the other enrichment options.

[Endpoint Reference](https://docs.promptlayer.com/reference/track-prompt.md)

To associate requests with a prompt from the prompt registry, run the code

```python Python theme={null}
promptlayer_client.track.prompt(
  request_id=pl_request_id, 
  prompt_name="example-2",
  prompt_input_variables=input_variables,
  version=2
)
```

```js JavaScript theme={null}
promptLayerClient.track.prompt({
  request_id: pl_request_id, 
  prompt_name: "example-2",
  prompt_input_variables: input_variables,
  version: 2
})
```

```bash REST theme={null}
curl --request POST \
  --url https://api.promptlayer.com/rest/track-prompt \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: pl_<YOUR API KEY>' \
  --data '{
    "request_id": "<REQUEST ID>",
    "prompt_name": "<PROMPT TEMPLATE NAME>",
    "prompt_input_variables": <PROMPT TEMPLATE INPUT VARIABLES>,
    "version": <PROMPT TEMPLATE VERSION NUMBER>
  }'
```

Where `prompt_name` is a prompt in your prompt registry, `prompt_input_variables` is a dictionary corresponding to the input variables you formatted the prompt with, and `version` is the version of the prompt you are trying to track. `version` is optional, by default it will track the newest version of the prompt.

This information will appear on your dashboard under your request and prompt template pages.

![score](https://mintcdn.com/promptlayer/v0RzaTvbzopITX7U/images/tracking-template-ui.png?fit=max\&auto=format\&n=v0RzaTvbzopITX7U\&q=85\&s=62cf872a1e4808489e25304b43c43284)

You can also use prompt [template release labels](https://docs.promptlayer.com/features/prompt-registry.md#release-labels) instead of a version number.

```python Python theme={null}
promptlayer_client.track.prompt(
  request_id=pl_request_id, 
  prompt_name="example-2",
  prompt_input_variables=input_variables,
  label="prod"
)
```

```js JavaScript theme={null}
promptLayerClient.track.prompt({
  request_id: pl_request_id, 
  prompt_name: "example-2",
  prompt_input_variables: input_variables,
  label: "prod"
})
```

```bash REST theme={null}
curl --request POST \
  --url https://api.promptlayer.com/rest/track-prompt \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: pl_<YOUR API KEY>' \
  --data '{
    "request_id": "<REQUEST ID>",
    "prompt_name": "<PROMPT TEMPLATE NAME>",
    "prompt_input_variables": <PROMPT TEMPLATE INPUT VARIABLES>,
    "label": "<YOUR PROMPT VERSION LABEL>"
  }'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.