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

# PromptLayer

> Learn how to export LLM Gateway traces to PromptLayer using OpenTelemetry integration.

This guide provides instructions for integrating [PromptLayer](https://www.promptlayer.com) with the TrueFoundry AI Gateway to export OpenTelemetry traces.

## What is PromptLayer?

PromptLayer is an LLM observability and prompt management platform that accepts OpenTelemetry traces over OTLP/HTTP. It ingests GenAI-standard OTLP spans and converts them into structured trace views, request logs, and analytics dashboards for monitoring and debugging LLM workflows.

### Key Features of PromptLayer

* **[Trace Observability](https://docs.promptlayer.com/features/opentelemetry#opentelemetry)**: Ingests OTLP spans and renders them as LLM call traces with inputs, outputs, token usage, and model metadata — visible under the **Traces** section of the dashboard.
* **[Prompt Management](https://docs.promptlayer.com/features/prompt-registry)**: Version-controlled prompt registry that links deployed prompts to observed traces for side-by-side comparison and evaluation.
* **[Analytics & Evaluation](https://docs.promptlayer.com/why-promptlayer/analytics)**: Aggregated dashboards for latency, cost, and quality across LLM providers and prompt versions.

## Prerequisites

Before integrating PromptLayer with TrueFoundry, ensure you have:

1. **TrueFoundry Account**: Create a [TrueFoundry account](https://www.truefoundry.com/register) and follow the instructions in our [Gateway Quick Start Guide](https://docs.truefoundry.com/gateway/quick-start).
2. **PromptLayer Account**: Sign up at [promptlayer.com](https://www.promptlayer.com) and have access to your workspace to retrieve an API key.

## Integration Steps

<Steps>
  <Step title="Get Your PromptLayer API Key">
    1. Log into your PromptLayer workspace.
    2. Click **Settings** in the bottom-left sidebar.
    3. Select **PromptLayer API Keys** under the Workspace section.
    4. Click **Generate New API Key** and copy the key.

    <Frame>
      <img src="https://mintcdn.com/truefoundry/SOHVjDyvW8egTJeq/images/promptlayer_apikey.png?fit=max&auto=format&n=SOHVjDyvW8egTJeq&q=85&s=5b697b61260df28af60b62492d5fad38" alt="PromptLayer Settings page showing the PromptLayer API Keys section with existing keys listed" width="3024" height="1716" data-path="images/promptlayer_apikey.png" />
    </Frame>

    <Tip>
      Create separate keys for different environments (e.g. **prod** and **dev**) so you can rotate them independently without affecting all integrations.
    </Tip>
  </Step>

  <Step title="Configure OTEL Export in TrueFoundry">
    1. Go to **AI Gateway** → **Settings** in the TrueFoundry dashboard.
    2. Scroll down to the **OTEL Config** section and click the edit (✏️) button.

    <Frame>
      <img src="https://mintcdn.com/truefoundry/Hferxd_RcEAacXkN/images/steps_to_configure_endpoint_in_tfy.png?fit=max&auto=format&n=Hferxd_RcEAacXkN&q=85&s=d6b1ca5775dd1fd1ed63b063749e1af7" alt="TrueFoundry AI Gateway Settings page showing the OTEL Config section with Traces Endpoint and Headers highlighted" width="3018" height="1716" data-path="images/steps_to_configure_endpoint_in_tfy.png" />
    </Frame>

    3. Enable the **Otel Traces Exporter Configuration** toggle and fill in:

    | Field            | Value                                   |
    | ---------------- | --------------------------------------- |
    | **Toggle**       | Enabled                                 |
    | **Protocol**     | HTTP Configuration                      |
    | **Endpoint**     | `https://api.promptlayer.com/v1/traces` |
    | **Encoding**     | Proto                                   |
    | **Header Key**   | `X-API-KEY`                             |
    | **Header Value** | `<your-promptlayer-api-key>`            |

    <Frame>
      <img src="https://mintcdn.com/truefoundry/Hferxd_RcEAacXkN/images/traces_otel_config_in_tfy.png?fit=max&auto=format&n=Hferxd_RcEAacXkN&q=85&s=f4447801dcfa119d96c02736ffb217ab" alt="TrueFoundry Configure Settings for OTEL Config modal showing the Traces Exporter filled in with the PromptLayer endpoint and X-API-KEY header" width="1568" height="1474" data-path="images/traces_otel_config_in_tfy.png" />
    </Frame>

    4. Click **Save** to apply the configuration.

    <Note>
      PromptLayer only accepts OTLP traces via its `/v1/traces` endpoint. It does not expose an OTLP metrics ingestion endpoint, so the Metrics Exporter should be left disabled. Make sure the header key is entered as **X-API-KEY** in all caps — PromptLayer's API enforces this exact casing.
    </Note>
  </Step>

  <Step title="Verify the Integration">
    1. Make a request through the TrueFoundry AI Gateway (via the Playground or any API call).
    2. Log into your PromptLayer dashboard and click **Traces** in the left sidebar.
    3. Confirm that spans from `tfy-llm-gateway` are appearing with the full span hierarchy — including model calls, MCP gateway spans, and HTTP calls.

    <Frame>
      <img src="https://mintcdn.com/truefoundry/SOHVjDyvW8egTJeq/images/promptlayer_traces.png?fit=max&auto=format&n=SOHVjDyvW8egTJeq&q=85&s=ef8226270d2670712d8c0f2c0a418fb4" alt="PromptLayer Traces page showing span hierarchy from TrueFoundry AI Gateway including AgentResponse, ChatCompletion, and Model spans with Success status" width="3022" height="1718" data-path="images/promptlayer_traces.png" />
    </Frame>

    <Tip>
      PromptLayer ingests spans asynchronously. Allow up to 60 seconds after your first gateway request before checking the Traces view.
    </Tip>
  </Step>
</Steps>

## Configuration Reference

| Configuration         | Value                                   |
| --------------------- | --------------------------------------- |
| **Traces Endpoint**   | `https://api.promptlayer.com/v1/traces` |
| **Metrics Endpoint**  | Not supported by PromptLayer            |
| **Protocol**          | HTTP                                    |
| **Encoding**          | Proto                                   |
| **Auth Header Key**   | `X-API-KEY`                             |
| **Auth Header Value** | Your PromptLayer API key                |
