> ## 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.

# Get Prompt

> Fetches a compiled prompt using the provided prompt ID, version, and variables.

## SDK usage

`url` and `api_key` (or `apiKey`) default to the `OPENLIT_URL` and `OPENLIT_API_KEY` environment variables if you don't pass them explicitly.

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import openlit

    response = openlit.get_prompt(
      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?'
      }
    }
    ```

    `url`, `api_key`, `name`, `prompt_id`, `version`, `should_compile`, `variables`, and `meta_properties` are all available parameters, matching the request body above.
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import Openlit from 'openlit';

    const response = await Openlit.getPrompts({
      name: "prompt_name",
      shouldCompile: true,
      variables: {
        name: "John",
      }
    });

    console.log(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?'
      }
    }
    ```

    `url`, `apiKey`, `name`, `promptId`, `version`, `shouldCompile`, `variables`, and `metaProperties` are all available parameters, matching the request body above.
  </Tab>
</Tabs>


## OpenAPI

````yaml POST /api/prompt/get-compiled
openapi: 3.0.0
info:
  title: Get Compiled Prompt API
  description: An API to fetch compiled prompts by providing necessary parameters.
  version: 1.0.0
servers:
  - url: http://localhost:3000
security: []
paths:
  /api/prompt/get-compiled:
    post:
      summary: Get Compiled Prompt
      description: >-
        Fetches a compiled prompt using the provided prompt ID, version, and
        variables.
      operationId: getCompiledPrompt
      requestBody:
        required: true
        content:
          text/plain:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: tester
                promptId:
                  type: string
                  format: uuid
                  example: a7a55e48-1588-44ee-99e2-d9de5c026238
                version:
                  type: string
                  example: 1.0.0
                metaProperties:
                  type: object
                  additionalProperties: true
                compile:
                  type: boolean
                  example: true
                variables:
                  type: object
                  properties:
                    name:
                      type: string
                      example: John
      responses:
        '200':
          description: Successfully retrieved compiled prompt.
          content:
            application/json:
              schema:
                type: object
                properties:
                  err:
                    type: object
                    nullable: true
                  res:
                    type: object
                    properties:
                      promptId:
                        type: string
                        format: uuid
                        example: a7a55e48-1588-44ee-99e2-d9de5c026238
                      versionId:
                        type: string
                        format: uuid
                        example: 2d44f89a-2222-498d-869b-795296496ca3
                      name:
                        type: string
                        example: tester
                      version:
                        type: string
                        example: 1.0.0
                      tags:
                        type: array
                        items:
                          type: string
                      metaProperties:
                        type: object
                        additionalProperties: true
                      prompt:
                        type: string
                        example: Hello {{name}}
                      compiledPrompt:
                        type: string
                        example: Hello John
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````