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

# Prompts

> Build, version, and manage prompts for LLM applications. Configure models, variables, and structured outputs through AI Studio or the API.

**Prompts** store all configuration for interacting with a model: system instructions, messages, model selection, and parameters. A Prompt can be reused across [Playgrounds](/docs/ai-studio/prompts/playgrounds), [Experiments](/docs/experiments/overview), [Deployments](/docs/ai-studio/ai-engineering/deployments), and [Agents](/docs/ai-studio/ai-engineering/build-agents).

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/2bHNizT-Lic?si=9NEWmAiNwUpxPNjI" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen />

## Use Cases

<AccordionGroup>
  <Accordion title="Standardize AI Behavior Across Teams" icon="users">
    Use prompts as shared instructions so every team and application produces consistent, aligned outputs.
  </Accordion>

  <Accordion title="Turn AI Use Cases into Reusable Assets" icon="layer-group">
    Package prompts as configurable building blocks that can be reused across products, workflows, and experiments.
  </Accordion>

  <Accordion title="Control Model Output Without Code Changes" icon="sliders">
    Adjust behavior, tone, and structure by editing prompts instead of modifying application logic.
  </Accordion>

  <Accordion title="Scale AI Features Safely" icon="display-chart-up">
    Roll out improvements, A/B test variations, and manage risk through prompt versioning and controlled updates.
  </Accordion>

  <Accordion title="Connect AI to Business Context" icon="link">
    Embed domain rules, policies, and structured outputs directly into prompts to align AI with business needs.
  </Accordion>
</AccordionGroup>

## Create a Prompt

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    <Steps>
      <Step title="Navigate to a Project">
        Open a [Project](/docs/ai-studio/get-started/projects) and click the **`+`** button at the top.
      </Step>

      <Step title="Select Prompt">
        Choose **Prompt** from the menu. The Prompt editor opens in AI Studio.
      </Step>
    </Steps>

    Standalone prompts are stored in the Project and can be reused across [Playgrounds](/docs/ai-studio/prompts/playgrounds), [Experiments](/docs/experiments/overview), [Agents](/docs/ai-studio/ai-engineering/build-agents), and [Deployments](/docs/ai-studio/ai-engineering/deployments).
  </Tab>

  <Tab title="API & SDK" icon="code">
    Create a Prompt using the [Create a Prompt API](/reference/prompts/create-a-prompt). The payload defines the name, model, messages, parameters, and metadata.

    <CodeGroup>
      ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
      curl --request POST \
           --url https://api.orq.ai/v2/prompts \
           --header 'accept: application/json' \
           --header 'authorization: Bearer ORQ_API_KEY' \
           --header 'content-type: application/json' \
           --data '{
        "prompt_config": {
          "model_parameters": {
            "responseFormat": null,
            "temperature": 1,
            "maxTokens": 256,
            "topP": 0.7,
            "frequencyPenalty": 0,
            "presencePenalty": 0
          },
          "model": "openai/gpt-4o",
          "model_type": "vision",
          "provider": "openai",
          "messages": [
            {
              "role": "system",
              "content": "You are a helpful assistant"
            }
          ]
        },
        "display_name": "MyPrompt",
        "path": "Default/Prompts",
        "metadata": {
          "language": "English"
        },
        "description": "Prompt Description"
      }'
      ```

      ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
      import { Orq } from "@orq-ai/node";

      const orq = new Orq({
        apiKey: process.env["ORQ_API_KEY"] ?? "",
      });

      const result = await orq.prompts.create({
        displayName: "MyPrompt",
        promptConfig: {
          modelParameters: {
            responseFormat: null,
            temperature: 1,
            maxTokens: 256,
            topP: 0.7,
            frequencyPenalty: 0,
            presencePenalty: 0,
          },
          model: "openai/gpt-4o",
          modelType: "vision",
          provider: "openai",
          messages: [
            {
              role: "system",
              content: "You are a helpful assistant",
            },
          ],
        },
        path: "Default/Prompts",
        metadata: {
          language: "English",
        },
      });

      console.log(result);
      ```

      ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
      from orq_ai_sdk import Orq
      import os

      with Orq(
          api_key=os.getenv("ORQ_API_KEY", ""),
      ) as orq:
          res = orq.prompts.create(request={
              "display_name": "MyPrompt",
              "prompt_config": {
                  "model_parameters": {
                      "responseFormat": None,
                      "temperature": 1,
                      "maxTokens": 256,
                      "topP": 0.7,
                      "frequencyPenalty": 0,
                      "presencePenalty": 0,
                  },
                  "model": "openai/gpt-4o",
                  "model_type": "vision",
                  "provider": "openai",
                  "messages": [{
                      "role": "system",
                      "content": "You are a helpful assistant"
                  }],
              },
              "path": "Default/Prompts",
              "metadata": {"language": "English"},
              "description": "Prompt Description",
          })

          print(res)
      ```
    </CodeGroup>

    The response includes the prompt `_id` needed for future updates or retrieval.

    <Tip>See the full [Create a Prompt API reference](/reference/prompts/create-a-prompt).</Tip>
  </Tab>
</Tabs>

### Choose a Model

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    Select a model from the model picker at the top of the Prompt editor.

    <Info>
      A model must be available through the [AI Gateway](/docs/ai-studio/ai-gateway/add-models) to appear in the picker.
    </Info>

    <img src="https://mintcdn.com/orqai/4YNqGRNpuZNyo0_T/images/prompt-model-selection-410.png?fit=max&auto=format&n=4YNqGRNpuZNyo0_T&q=85&s=cf6cb9fe242759e9b0089d807adaf7bb" alt="Choose a Model" width="555" height="174" data-path="images/prompt-model-selection-410.png" />
  </Tab>
</Tabs>

### Model Parameters

<AccordionGroup>
  <Accordion title="Temperature" icon="flame">
    Controls creativity and predictability. Higher values produce more diverse, surprising responses. Lower values produce more predictable output that sticks closely to learned patterns.
  </Accordion>

  <Accordion title="Max Tokens" icon="hashtag">
    Sets the upper limit on tokens the model can produce in a single output. Prevents excessively long responses while ensuring enough room for a complete answer.
  </Accordion>

  <Accordion title="Top K" icon="arrow-up-right">
    Narrows the model's choices to the k most likely tokens at each generation step. Helps refine output to follow particular patterns or meet specific criteria.
  </Accordion>

  <Accordion title="Top P" icon="sliders">
    Nucleus sampling. Selects a pool of likely words based on a probability threshold, balancing creativity with coherence.
  </Accordion>

  <Accordion title="Frequency Penalty" icon="repeat">
    Discourages the model from reusing the same words or phrases, encouraging richer and more varied language.
  </Accordion>

  <Accordion title="Presence Penalty" icon="megaphone">
    Discourages repeated topics or ideas rather than specific words. Higher values lead to more creative and diverse responses.
  </Accordion>
</AccordionGroup>

### Messages

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    Select **Add Message** in the Prompt Template panel to add a message. Messages define the context the model receives before generating a response.

    <Frame caption="The prompt template used as context for the language model.">
      <img src="https://mintcdn.com/orqai/4YNqGRNpuZNyo0_T/images/prompt-template-410.png?fit=max&auto=format&n=4YNqGRNpuZNyo0_T&q=85&s=5158ca18e199c9bc7fd2631d591328b9" alt="The prompt template used as context for the language model." width="913" height="580" data-path="images/prompt-template-410.png" />
    </Frame>
  </Tab>
</Tabs>

#### Roles

When adding a message, choose a role to define how the model interprets it:

| Role          | Description                                                                                               | Example                                                                            |
| ------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| **System**    | A guideline or context for the language model, directing how it should interpret and respond to requests. | "You are an expert botanist. Respond briefly to questions with one-line answers."  |
| **User**      | An actual query posed by the user.                                                                        | "Which plants thrive in shady environments?"                                       |
| **Assistant** | Responses to user queries by the language model.                                                          | "Ferns, Hostas, and Hydrangeas are some plants that thrive in shady environments." |

#### Variables

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    Use `{{variable_name}}` syntax inside a message to declare a dynamic input. All declared inputs appear in the **Inputs** block at the top-right of the page, where default values can be set for testing.

    The example below shows the inputs being set while running the prompt in the Playground.

    <Frame caption="Inputs being set and overridden while running a prompt in the Playground.">
      ![Inputs block in the Playground with a variable value being overridden while running a prompt.](https://files.readme.io/a4e6f3a-inputs720fps30.gif)
    </Frame>

    To pass values at runtime in a **Deployment**, see [Variables and Prompt Templating](/docs/ai-studio/ai-engineering/deployments#variables-and-prompt-templating).
  </Tab>
</Tabs>

### Prompt Generator

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    Select the **Generate Prompt** button next to the Role Selector to open the prompt generation assistant.

    <img src="https://mintcdn.com/orqai/x_6IXnot9ETOc_0g/images/docs/2848e0072c425d598d2d841d3531d6d6283420cb9cc34eb90f570dd1944ed2e8-Screenshot_2024-10-07_at_17.19.38.png?fit=max&auto=format&n=x_6IXnot9ETOc_0g&q=85&s=54ce93127c4d908b6cc16bcfeeb77b39" alt="The Generate Prompt button located next to the Role Selector in the prompt editor." width="2294" height="230" data-path="images/docs/2848e0072c425d598d2d841d3531d6d6283420cb9cc34eb90f570dd1944ed2e8-Screenshot_2024-10-07_at_17.19.38.png" />

    * Select **Copy** to copy the generated prompt to the clipboard.
    * Select **Apply** to overwrite the current prompt with the generated one.

          <img src="https://mintcdn.com/orqai/MdV1JwnMjT_YJyPn/images/prompt-generator-assistant.png?fit=max&auto=format&n=MdV1JwnMjT_YJyPn&q=85&s=d22d62177f71d96e1f7650b0b2126842" alt="The prompt generation assistant showing a generated prompt with Copy and Apply buttons." width="1426" height="997" data-path="images/prompt-generator-assistant.png" />
  </Tab>
</Tabs>

## Fetch a Prompt

<Tabs>
  <Tab title="API & SDK" icon="code">
    Retrieve a Prompt by its ID using the [Retrieve a Prompt API](/reference/prompts/retrieve-a-prompt).

    <CodeGroup>
      ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
      curl --request GET \
           --url https://api.orq.ai/v2/prompts/PROMPT_ID \
           --header 'accept: application/json' \
           --header 'authorization: Bearer ORQ_API_KEY'
      ```

      ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
      import { Orq } from "@orq-ai/node";

      const orq = new Orq({
        apiKey: process.env["ORQ_API_KEY"] ?? "",
      });

      const result = await orq.prompts.retrieve({
        id: "<id>",
      });

      console.log(result);
      ```

      ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
      from orq_ai_sdk import Orq
      import os

      with Orq(
          api_key=os.getenv("ORQ_API_KEY", ""),
      ) as orq:
          res = orq.prompts.retrieve(id="<id>")
          print(res)
      ```
    </CodeGroup>

    <Tip>See the full [Retrieve a Prompt API reference](/reference/prompts/retrieve-a-prompt).</Tip>
  </Tab>
</Tabs>
