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

# Working with Prompts

> Learn how to create, manage, and optimize AI prompts in Hyperleap AI

Prompts in Hyperleap AI are pre-configured instructions that guide AI responses for your specific use cases. They act as templates that can be reused across your organization, ensuring consistent and accurate AI interactions while reducing prompt engineering effort.

Simple 4 step process to start using Prompts

<Steps>
  <Step title="Create and Configure">
    Design your AI feature in our API Console.

    * Define the Prompt template, add dynamic variables or import pre-configured Prompt from Prompt library
    * Set your preferred AI model
    * Add Sources to provide context
    * Fine tune the Prompt configuration

    <Card title="Detailed Guide: Create and Configure Prompt" icon="wand-magic-sparkles" href="/guides/prompts/create-prompt">
      Learn the step-by-step process of creating and configuring your first prompt
    </Card>
  </Step>

  <Step title="Save and Test">
    After configuration, your Prompt will have a dedicated REST API endpoint. You can test each Prompt in our playground prior to deployment.

    * After testing, you can publish the Prompt to your Workspace for reuse by other users
  </Step>

  <Step title="Integrate via API">
    To integrate with the API, perform a REST API call from your application. Send your variables in a JSON format, and the system will handle the AI context and state management. This is compatible with any programming language or framework.

    ```javascript theme={null}
    // Example API integration using JavaScript
    const response = await fetch('https://api.hyperleapai.com/prompt-runs/execute', {
      method: 'POST',
      headers: {
        'x-hl-api-key': 'your_api_key_here',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        prompt_id: 'your_prompt_id',
        prompt_version_id: 'your_prompt_version_id',
        replacements: {
          variable_name: 'variable_value'
          ...
        }
      })
    });

    const result = await response.json();
    ```

    <Note>
      For detailed API specifications and more examples, check out our [Prompts API Reference](/api-reference/prompts/overview). You'll find complete documentation of all available endpoints, parameters, and response formats.
    </Note>
  </Step>

  <Step title="Deploy and Monitor">
    Ensure your Prompts deliver consistent responses as configured. You can monitor usage, track costs, and adjust settings without code changes. Access audit logs to review interactions and gather feedback for continuous improvement.
  </Step>
</Steps>

## How Prompts Work

Understand how Prompts work in Hyperleap AI under the hood

<CardGroup cols={2}>
  <Card title="Input Processing" icon="inbox-in">
    Your Prompt template receives inputs from your configured fields. These inputs are validated and prepared for processing.
  </Card>

  <Card title="Variable Substitution" icon="arrows-rotate">
    Dynamic variables in your Prompt are replaced with actual values, allowing for
    flexible and reusable Prompt templates.
  </Card>

  <Card title="Context Integration" icon="database">
    Relevant context from your connected data sources is incorporated, enriching
    the prompt with necessary background information.
  </Card>

  <Card title="AI Processing" icon="microchip">
    The final Prompt is processed by our AI engine to generate responses, leveraging advanced language models for optimal results.
  </Card>
</CardGroup>

## Common Use Cases

<CardGroup cols={2}>
  <Card title="Content Generation">
    Create templates for consistent content creation across different formats
  </Card>

  <Card title="Data Analysis">
    Structure prompts for extracting insights from data
  </Card>

  <Card title="Customer Support">
    Design response templates for common customer queries
  </Card>

  <Card title="Process Automation">
    Build prompts for automated decision-making workflows
  </Card>
</CardGroup>

## Sharing & Permissions

Prompts can be shared with your team through **Workspaces**, with role-based access control to manage what each team member can do.

### Permission Matrix

| Action             | Owner | Admin | Contributor | Reader | Guest |
| ------------------ | ----- | ----- | ----------- | ------ | ----- |
| Run Prompt         | ✓     | ✓     | ✓           | ✓      | ✓     |
| View Details       | ✓     | ✓     | ✓           | ✓      | ✗     |
| Edit/Add Versions  | ✓     | ✓     | ✓           | ✗      | ✗     |
| Delete             | ✓     | ✓     | ✗           | ✗      | ✗     |
| Manage Permissions | ✓     | ✗     | ✗           | ✗      | ✗     |

For more details on workspace roles, see [Managing Workspaces](/guides/workspace).

## Troubleshooting

Common issues you might encounter and how to resolve them:

<AccordionGroup>
  <Accordion title="Variable Substitution Errors">
    **Issue**: Prompt variables not being replaced with actual values.

    **Solutions**:

    * Verify variable names match exactly in both Prompt template and input
    * Check for proper syntax: `{{variableName}}`
    * Ensure all required variables are provided in the request
    * Use the Studio interface to validate variable substitution
  </Accordion>

  <Accordion title="Context Length Exceeded">
    **Issue**: Total Prompt length including context exceeds model limits.
    **Solutions**: - Reduce context length by summarizing or chunking data - Use
    shorter Prompt templates - Consider using our automatic context truncation
    feature - Monitor token count in Studio before deployment
  </Accordion>

  <Accordion title="Response Format Mismatch">
    **Issue**: AI responses not matching expected format structure.

    **Solutions**:

    * Use format instructions in your Prompt template
    * Implement response validation
    * Test Prompts in Studio before production use
    * Consider using our structured output templates
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={3}>
  <Card title="Prompt Library" icon="wand-magic-sparkles" href="https://studio.hyperleapai.com/prompt-library">
    Access our Prompt library and use pre-configured Prompts
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/prompts/overview">
    Learn how to integrate Prompts programmatically using our API
  </Card>

  <Card title="Hyperleap AI Studio" icon="browser" href="https://studio.hyperleapai.com">
    Manage your Prompts through our intuitive web interface - no coding required
  </Card>
</CardGroup>

## Need Help?

* Check our [FAQ](/guides/faq)
* Contact [Support](mailto:support@hyperleap.ai)
