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

# Testing Prompts

> Test your prompts with the built-in test runner

Endprompt includes a powerful test runner that lets you validate prompts before deploying to production. Test with single requests, bulk CSV uploads, or saved test datasets.

## The Test Runner

Every prompt has a **Test** button that opens the test runner:

* Auto-generated form based on your input schema
* Real-time execution against the actual LLM
* Response preview with timing and token usage
* History of past test runs

## Single Request Testing

<Steps>
  <Step title="Open the Test Runner">
    Click **Test** next to any prompt in your endpoint.
  </Step>

  <Step title="Fill in the Form">
    The form is generated from your input schema. Required fields are marked. Image fields display a file upload control (drag & drop or click to browse).
  </Step>

  <Step title="Select Options">
    * **Bypass Cache**: Force a fresh LLM call
    * **Model Override**: Test with a different model
  </Step>

  <Step title="Run Test">
    Click **Run Test** or press `Ctrl/Cmd + Enter`.
  </Step>

  <Step title="Review Response">
    See the JSON response, latency, and token usage.
  </Step>
</Steps>

### Test Results Panel

After running a test, you'll see:

| Section        | Description                   |
| -------------- | ----------------------------- |
| **Response**   | The JSON output from the LLM  |
| **Latency**    | Time taken for the request    |
| **Tokens**     | Input and output token counts |
| **Cost**       | Estimated cost of the request |
| **Raw Output** | Unprocessed LLM response      |

<Tip>
  Toggle between **Formatted** and **Raw** views to debug JSON parsing issues.
</Tip>

## Bulk CSV Testing

Test multiple inputs at once by uploading a CSV file:

<Steps>
  <Step title="Prepare Your CSV">
    Create a CSV with columns matching your input field names:

    ```csv theme={null}
    text,max_length,tone
    "First document to summarize",100,formal
    "Second document here",150,casual
    "Third document",100,formal
    ```
  </Step>

  <Step title="Open Bulk Test">
    In the test runner, click **Bulk Test** or **Import CSV**.
  </Step>

  <Step title="Upload CSV">
    Select your CSV file.
  </Step>

  <Step title="Review Mapping">
    Confirm columns map to the correct input fields.
  </Step>

  <Step title="Run All">
    Click **Run All Tests** to execute each row.
  </Step>

  <Step title="Review Results">
    See success/failure status and responses for each row.
  </Step>
</Steps>

### CSV Best Practices

<AccordionGroup>
  <Accordion title="Use quoted strings" icon="quote-right">
    Wrap text containing commas in double quotes: `"Hello, world"`
  </Accordion>

  <Accordion title="Match field names exactly" icon="equals">
    Column headers must match your input schema field names.
  </Accordion>

  <Accordion title="Start small" icon="minimize">
    Test with 5-10 rows first before running hundreds.
  </Accordion>

  <Accordion title="Include edge cases" icon="code-branch">
    Add rows with empty optional fields, long text, special characters.
  </Accordion>
</AccordionGroup>

## Saved Test Datasets

Save frequently-used test data for quick access:

<Steps>
  <Step title="Run a Test">
    Execute a test with your desired inputs.
  </Step>

  <Step title="Save Dataset">
    Click **Save as Dataset** and give it a name.
  </Step>

  <Step title="Reuse Later">
    Select the saved dataset from the dropdown to load those inputs.
  </Step>
</Steps>

Saved datasets are useful for:

* Regression testing after prompt changes
* Comparing outputs across different prompts
* Onboarding team members with realistic examples

## Comparing Prompts

Test the same input against multiple prompts:

1. Open the endpoint's Testing tab
2. Select multiple prompts to compare
3. Enter your test input
4. Run the comparison
5. View results side-by-side

This helps you:

* Compare model performance (GPT-4 vs Claude)
* Evaluate prompt variations
* Choose the best approach before going live

## Testing with Image Inputs

When your endpoint has image input fields:

1. The test form shows a **file upload** control for each image field
2. Drag & drop an image or click to browse
3. Supported formats: **JPEG, PNG, WebP**
4. An image preview is displayed after upload
5. Images are automatically base64-encoded before sending

<Note>
  Bulk CSV testing does **not** support image inputs. Use single request testing for image workflows.
</Note>

## Viewing Image Outputs

When an endpoint generates images:

1. An **Images** tab appears in the test results panel
2. Generated images are displayed in a card grid
3. Click the **Download** button on any image to save it
4. If the model revised your prompt, the revised prompt is shown below the image

## Test History

All test runs are saved in your history:

* View past test inputs and outputs
* Re-run previous tests
* Track how responses change over time

<Note>
  Test history is separate from production logs. Tests don't count against your API usage limits.
</Note>

## Testing Best Practices

<CardGroup cols={2}>
  <Card title="Test Edge Cases" icon="code-branch">
    Empty strings, very long inputs, special characters, missing optional fields
  </Card>

  <Card title="Test Realistic Data" icon="database">
    Use real-world examples, not just "test" and "hello world"
  </Card>

  <Card title="Test Before Promoting" icon="shield-check">
    Always test Draft prompts before promoting to Live
  </Card>

  <Card title="Save Good Datasets" icon="floppy-disk">
    Build a library of test cases you can reuse
  </Card>
</CardGroup>

## Debugging Failed Tests

If your test fails or returns unexpected results:

### Check Input Validation

```json theme={null}
{
  "error": "validation_error",
  "message": "Field 'text' is required"
}
```

**Solution**: Ensure all required fields are provided.

### Check JSON Parsing

```json theme={null}
{
  "error": "parse_error",
  "message": "Invalid JSON in response"
}
```

**Solution**: Update your prompt to explicitly request valid JSON output.

### Check Token Limits

```json theme={null}
{
  "error": "token_limit_exceeded",
  "message": "Response truncated due to max_tokens"
}
```

**Solution**: Increase max\_tokens in prompt settings or ask for shorter responses.

### Check Rate Limits

```json theme={null}
{
  "error": "rate_limit_exceeded",
  "message": "Too many requests"
}
```

**Solution**: Wait and retry, or reduce test frequency.

## Keyboard Shortcuts

| Shortcut           | Action            |
| ------------------ | ----------------- |
| `Ctrl/Cmd + Enter` | Run test          |
| `Ctrl/Cmd + S`     | Save test input   |
| `Escape`           | Close test runner |

## Next Steps

<CardGroup cols={2}>
  <Card title="Prompt Snippets" icon="puzzle-piece" href="/prompts/snippets">
    Create reusable template fragments
  </Card>

  <Card title="View Logs" icon="list" href="/guides/logs-and-monitoring">
    Monitor execution in production
  </Card>
</CardGroup>
