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

# Input Schema

> Define what data your endpoint accepts

The input schema defines what data your endpoint accepts. When a request comes in, Endprompt validates it against your schema before processing—rejecting invalid requests with clear error messages.

## Why Define Input Schema?

<CardGroup cols={2}>
  <Card title="Automatic Validation" icon="shield-check">
    Invalid requests are rejected before hitting the LLM, saving costs
  </Card>

  <Card title="Clear Documentation" icon="book">
    Your OpenAPI docs are auto-generated from your schema
  </Card>

  <Card title="Type Safety" icon="brackets-curly">
    Ensure prompts receive data in the expected format
  </Card>

  <Card title="Default Values" icon="pen">
    Provide sensible defaults for optional fields
  </Card>
</CardGroup>

## Adding Input Fields

Navigate to your endpoint's **Input Schema** tab and click **Add Field**.

### Field Configuration

| Property        | Required | Description                                              |
| --------------- | -------- | -------------------------------------------------------- |
| **Name**        | Yes      | Field identifier used in templates (`{{ inputs.name }}`) |
| **Type**        | Yes      | Data type (see types below)                              |
| **Required**    | No       | Whether the field must be provided                       |
| **Default**     | No       | Value to use if field is not provided                    |
| **Description** | No       | Help text shown in docs and test forms                   |

### Field Types

<Tabs>
  <Tab title="String">
    Text values of any length.

    ```json theme={null}
    {
      "name": "query",
      "type": "string",
      "required": true,
      "description": "The search query"
    }
    ```

    **Validation options:**

    * `minLength` — Minimum character count
    * `maxLength` — Maximum character count
    * `pattern` — Regex pattern to match
    * `enum` — List of allowed values
  </Tab>

  <Tab title="Number">
    Decimal numbers (floats).

    ```json theme={null}
    {
      "name": "temperature",
      "type": "number",
      "required": false,
      "default": 0.7
    }
    ```

    **Validation options:**

    * `minimum` — Minimum value
    * `maximum` — Maximum value
  </Tab>

  <Tab title="Integer">
    Whole numbers only.

    ```json theme={null}
    {
      "name": "max_results",
      "type": "integer",
      "required": false,
      "default": 10
    }
    ```

    **Validation options:**

    * `minimum` — Minimum value
    * `maximum` — Maximum value
  </Tab>

  <Tab title="Boolean">
    True or false values.

    ```json theme={null}
    {
      "name": "include_examples",
      "type": "boolean",
      "required": false,
      "default": false
    }
    ```
  </Tab>

  <Tab title="Array">
    Lists of values.

    ```json theme={null}
    {
      "name": "tags",
      "type": "array",
      "items": { "type": "string" },
      "required": false
    }
    ```

    **Validation options:**

    * `minItems` — Minimum array length
    * `maxItems` — Maximum array length
    * `items` — Schema for array elements
  </Tab>

  <Tab title="Object">
    Nested JSON objects.

    ```json theme={null}
    {
      "name": "options",
      "type": "object",
      "properties": {
        "format": { "type": "string" },
        "length": { "type": "integer" }
      }
    }
    ```
  </Tab>

  <Tab title="Image">
    Image inputs for vision and editing workflows. Images are sent as base64 data URIs.

    ```json theme={null}
    {
      "name": "photo",
      "type": "image",
      "required": true,
      "description": "The image to analyze"
    }
    ```

    **Supported formats:** JPEG, PNG, WebP

    <Warning>
      Image inputs are passed directly as visual context to the model — they are **not** available as Liquid template variables (`{{ inputs.photo }}` won't work). Your prompt template should describe what to do with the image; the image data is sent separately.
    </Warning>

    <Note>
      Requires a vision-capable model (GPT-4o, Claude 3 Sonnet/Opus, Gemini) for analysis, or an image generation model (gpt-image-1) for editing workflows.
    </Note>
  </Tab>
</Tabs>

## Validation Rules

Add validation rules to ensure data quality:

### String Validation

```json theme={null}
{
  "name": "email",
  "type": "string",
  "required": true,
  "minLength": 5,
  "maxLength": 254,
  "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
}
```

### Enum (Allowed Values)

```json theme={null}
{
  "name": "tone",
  "type": "string",
  "required": true,
  "enum": ["formal", "casual", "friendly", "professional"]
}
```

<Tip>
  Use enums when you have a fixed set of valid options. They generate dropdowns in the test form and are documented in OpenAPI.
</Tip>

### Number Ranges

```json theme={null}
{
  "name": "confidence_threshold",
  "type": "number",
  "required": false,
  "default": 0.8,
  "minimum": 0,
  "maximum": 1
}
```

### Array Limits

```json theme={null}
{
  "name": "categories",
  "type": "array",
  "items": { "type": "string" },
  "minItems": 1,
  "maxItems": 10
}
```

## Using Inputs in Prompts

Once defined, access input fields in your prompts using Liquid syntax:

```liquid theme={null}
Summarize the following {{ inputs.content_type }} content:

{{ inputs.text }}

{% if inputs.include_keywords %}
Also extract the top {{ inputs.keyword_count | default: 5 }} keywords.
{% endif %}

Keep the summary under {{ inputs.max_words | default: 100 }} words.
```

<Note>
  Use the `| default:` filter to provide fallback values for optional fields.
</Note>

## JSON Schema Preview

The Input Schema tab shows a live JSON Schema preview:

```json theme={null}
{
  "type": "object",
  "required": ["text"],
  "properties": {
    "text": {
      "type": "string",
      "description": "The content to summarize",
      "minLength": 10,
      "maxLength": 50000
    },
    "max_words": {
      "type": "integer",
      "description": "Maximum words in summary",
      "default": 100,
      "minimum": 10,
      "maximum": 1000
    },
    "format": {
      "type": "string",
      "description": "Output format",
      "enum": ["paragraph", "bullets", "numbered"],
      "default": "paragraph"
    }
  }
}
```

This schema is used for:

* Request validation
* OpenAPI documentation
* Test form generation

## Best Practices

<AccordionGroup>
  <Accordion title="Use descriptive names" icon="tag">
    Field names should be clear and self-documenting.

    ✅ `customer_feedback`\
    ❌ `cf`
  </Accordion>

  <Accordion title="Always add descriptions" icon="comment">
    Descriptions appear in docs and help users understand what to provide.
  </Accordion>

  <Accordion title="Set sensible defaults" icon="sliders">
    Optional fields should have reasonable defaults so users don't need to specify everything.
  </Accordion>

  <Accordion title="Validate early" icon="shield-check">
    Use minLength, maxLength, and patterns to catch bad data before it reaches the LLM.
  </Accordion>

  <Accordion title="Keep schemas flat" icon="layer-group">
    Avoid deeply nested objects. Flat schemas are easier to understand and template.
  </Accordion>
</AccordionGroup>

## Example: Complete Input Schema

Here's a full example for a content moderation endpoint:

| Field                 | Type    | Required | Default | Description                     |
| --------------------- | ------- | -------- | ------- | ------------------------------- |
| `content`             | string  | Yes      | —       | The content to moderate         |
| `content_type`        | string  | Yes      | —       | Type: text, image\_url, or html |
| `categories`          | array   | No       | all     | Categories to check             |
| `threshold`           | number  | No       | 0.7     | Confidence threshold (0-1)      |
| `include_explanation` | boolean | No       | false   | Include reasoning               |

## Next Steps

<CardGroup cols={2}>
  <Card title="Define Output Schema" icon="arrow-right-from-bracket" href="/endpoints/output-schema">
    Specify the structure of your endpoint's response
  </Card>

  <Card title="Create a Prompt" icon="wand-magic-sparkles" href="/prompts/create-prompt">
    Write the prompt that uses these inputs
  </Card>
</CardGroup>
