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

# Prompt Hub

> Manage prompts centrally, fetch versions, and use variables for dynamic prompts

The Prompt-Hub allows you to manage prompts, fetch specific versions of the prompt, and compile prompts with variables.

## Key features

* **Prompt Management**: Create, edit, and track different versions of your prompts.
* **Versioning**: Supports major, minor, and patch updates for clear version management.
* **Dynamic Variables**: Use `{{variableName}}` placeholders that are dynamically replaced at runtime.
* **Statistics**: View download stats and version history directly in the UI.

## Get started

<Steps>
  <Step title="List prompts">
    Get a quick overview of all prompts created.

    1. Navigate to the Prompt Hub in OpenLIT.
    2. Explore the available prompts listed.

    <Frame>
      <img src="https://mintcdn.com/openlit/bDceVwnmhemq49YN/images/docs-prompt-hub-list.png?fit=max&auto=format&n=bDceVwnmhemq49YN&q=85&s=5c310d1a654271585553dcc632c019ad" width="3024" height="1724" data-path="images/docs-prompt-hub-list.png" />
    </Frame>
  </Step>

  <Step title="Create or edit a prompt">
    Build new prompts or edit existing ones with ease.

    1. Click on **Create new** button to create a new prompt
    2. In the prompt editor, add the prompt name, Meta Properties and use placeholders like `{{variableName}}` to represent dynamic data that will be substituted when the prompt is compiled.
    3. Specify major, minor, or patch updates for versioning as you create or modify prompts.

    <Frame>
      <img src="https://mintcdn.com/openlit/bDceVwnmhemq49YN/images/docs-prompt-hub-create.png?fit=max&auto=format&n=bDceVwnmhemq49YN&q=85&s=380555a15bed9cf7bdf45e085c9a6aa5" width="3024" height="1724" data-path="images/docs-prompt-hub-create.png" />
    </Frame>
  </Step>

  <Step title="View prompt details" stepNumber=" ">
    Once the prompt is creaetd, You can see information about the prompt along with details on all past versions.

    <Frame>
      <img src="https://mintcdn.com/openlit/bDceVwnmhemq49YN/images/docs-prompt-hub-details.png?fit=max&auto=format&n=bDceVwnmhemq49YN&q=85&s=728348008657078792766c4e22e2ff1b" width="3024" height="1722" data-path="images/docs-prompt-hub-details.png" />
    </Frame>
  </Step>

  <Step title="Retrieve the prompt">
    <Steps>
      <Step title="Create an API Key">
        To authenticate your requests, you need an API key. Here's how you can create one:

        * Go to the OpenLIT.
        * Navigate to the **API Keys** page.
        * Click on **Create API Key**.
        * Enter a name for your API key.
        * Save the API key displayed. Ensure you store it securely as it will be used for authentication in the SDK.
      </Step>

      <Step title="Get prompt using the SDK">
        <Tabs>
          <Tab title="Python">
            Here's how you can fetch and compile a prompt in Python:

            ```python theme={null}
            import openlit

            response = openlit.get_prompt(
              url="http://127.0.0.1:3000", 
              api_key="_OPENLIT_API_KEY",  
              name="prompt_name",          
              should_compile=True,                
              variables={
                "name": "John",            
              },
            )

            print(response)               
            ```

            ```shell Output theme={null}
            {
              err: null,
              res: {
                  promptId: '88c4cbcd-87f9-4957-a37b-b41066e17471',
                  name: 'prompt_name',
                  version: '3.3.3',
                  tags: [ 'user', 'greeting' ],
                  metaProperties: { model: 'gpt4' },
                  prompt: 'Hello {{name}}, how are you today?',
                  compiledPrompt: 'Hello John, how are you today?'
              }
            }
            ```

            ### SDK parameters

            Below are the parameters for use with the SDK, formatted to indicate whether each is required or optional:

            | Parameter         | Description                                                                                    |
            | ----------------- | ---------------------------------------------------------------------------------------------- |
            | `url`             | Sets the OpenLIT URL. Defaults to the `OPENLIT_URL` environment variable.                      |
            | `api_key`         | Sets the OpenLIT API Key. Can also be provided via the `OPENLIT_API_KEY` environment variable. |
            | `name`            | Sets the name to fetch a unique prompt. Use this or `prompt_id`.                               |
            | `prompt_id`       | Sets the ID to fetch a unique prompt. Use this or `name`. Optional                             |
            | `version`         | Set to `True` to get the prompt with variable substitution.. Optional                          |
            | `shouldCompile`   | Boolean value that compiles the prompt using the provided variables. Optional                  |
            | `variables`       | Sets the variables for prompt compilation. Optional                                            |
            | `meta_properties` | Sets the meta-properties for storing in the prompt's access history metadata. Optional         |
          </Tab>

          <Tab title="Typescript">
            Here's how you can fetch and compile a prompt in Typescript/Javascript:

            ```typescript theme={null}
            import Openlit from 'openlit'; // Import OpenLIT

            const response = await Openlit.getPrompts({
              name: "prompt_name",     // Fetch the prompt by name
              shouldCompile: true,                 // Compile the prompt with provided variables
              variables: {
                name: "John",                // Pass variables for prompt compilation
              }
            });

            console.log(response);           // Print or process the fetched and compiled prompt
            ```

            ```shell Output theme={null}
            {
              err: null,
              res: {
                  promptId: '88c4cbcd-87f9-4957-a37b-b41066e17471',
                  name: 'prompt_name',
                  version: '3.3.3',
                  tags: [ 'user', 'greeting' ],
                  metaProperties: { model: 'gpt4' },
                  prompt: 'Hello {{name}}, how are you today?',
                  compiledPrompt: 'Hello John, how are you today?'
              }
            }
            ```

            ### SDK parameters

            Below are the parameters for use with the SDK, formatted to indicate whether each is required or optional:

            | Parameter        | Description                                                                                                     |
            | ---------------- | --------------------------------------------------------------------------------------------------------------- |
            | `url`            | Sets the OpenLIT URL. Defaults to the `OPENLIT_URL` environment variable or `http://127.0.0.1:3000` if not set. |
            | `apiKey`         | Sets the OpenLIT API Key. Can also be provided via the `OPENLIT_API_KEY` environment variable.                  |
            | `name`           | Sets the name to fetch a unique prompt. Use this or `promptId`.                                                 |
            | `promptId`       | Sets the ID to fetch a unique prompt. Use this or `name`. Optional                                              |
            | `version`        | Sets the version to retrieve a specific prompt. Optional                                                        |
            | `shouldCompile`  | Boolean value that compiles the prompt using the provided variables. Optional                                   |
            | `variables`      | Sets the variables for prompt compilation. Optional                                                             |
            | `metaProperties` | Sets the meta-properties for storing in the prompt's access history metadata.                                   |
          </Tab>

          <Tab title="API">
            To retrieve the prompt via an API request, Refer to the [**GET Prompt**](/latest/openlit/developer-resources/api-reference/endpoint/prompt-hub/get) API Reference Documentation.
          </Tab>
        </Tabs>
      </Step>
    </Steps>
  </Step>
</Steps>

***

<CardGroup cols={3}>
  <Card title="Manage LLM secrets" href="/latest/openlit/developer-resources/vault" icon="vault">
    Centrally store LLM API keys that applications can retrieve remotely without restarts
  </Card>

  <Card title="Create a dashboard" href="/latest/openlit/dashboards/overview" icon="grid">
    Create custom visualizations with flexible widgets, queries, and real-time AI monitoring
  </Card>

  <Card title="LLM playground" href="/latest/openlit/prompts-experiments/openground" icon="flask">
    Compare cost, duration, and response tokens across different LLMs to find the most efficient model
  </Card>
</CardGroup>

<Card title="Zero-code observability with the OpenLIT Controller" icon="tower-broadcast" href="/latest/controller/overview">
  Discover and instrument LLM traffic across Kubernetes, Docker, and Linux using eBPF — no code changes required.
</Card>
