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

# Image Generation & Vision

> Generate images, analyze visual content, and edit images with Endprompt

Endprompt supports three image workflows:

* **Image Generation** — Create images from text descriptions
* **Vision / Image Analysis** — Analyze images and return structured JSON
* **Image Editing** — Modify existing images based on instructions

## Setting Up Image Generation

Generate images by combining an image output field with an image generation model.

<Steps>
  <Step title="Create an Endpoint">
    Create an endpoint with text input fields for the image description.
  </Step>

  <Step title="Add an Image Output Field">
    In the **Output Schema** tab, add a field with type **Image**. This signals that the endpoint produces images instead of JSON.
  </Step>

  <Step title="Set Default Config (Optional)">
    Use the output field's **Example Value** to store default generation parameters as JSON:

    ```json theme={null}
    {
      "size": "1024x1024",
      "quality": "high"
    }
    ```
  </Step>

  <Step title="Create a Prompt">
    Create a prompt and select an image generation model (e.g., **gpt-image-1**).
  </Step>

  <Step title="Configure Custom Parameters">
    Open the **Custom Parameters** panel on the prompt to set generation options:

    ```json theme={null}
    [
      { "name": "size", "value": "1024x1536" },
      { "name": "quality", "value": "high" }
    ]
    ```
  </Step>

  <Step title="Write the Prompt">
    Write a descriptive prompt — no JSON output instructions needed. The rendered prompt is sent directly as the image description.

    ```liquid theme={null}
    A professional product photo of {{ inputs.product_name }}.
    Style: {{ inputs.style | default: "minimalist" }}.
    Background: clean white studio lighting.
    {{ inputs.additional_instructions }}
    ```
  </Step>

  <Step title="Test">
    Use the test runner to generate images and iterate on your prompt.
  </Step>
</Steps>

<Note>
  When an endpoint has image output fields, Endprompt automatically skips JSON output instructions and routes the request to the model's image generation API.
</Note>

## Setting Up Vision / Image Analysis

Analyze images and return structured data by combining image inputs with a vision-capable model.

<Steps>
  <Step title="Create an Endpoint">
    Create an endpoint for your analysis workflow.
  </Step>

  <Step title="Add an Image Input Field">
    In the **Input Schema** tab, add a field with type **Image**.
  </Step>

  <Step title="Add Text/JSON Output Fields">
    Define your output schema as normal (string, number, object, etc.).
  </Step>

  <Step title="Create a Prompt">
    Select a vision-capable model: **GPT-4o**, **Claude 3 Sonnet/Opus**, or **Gemini**.
  </Step>

  <Step title="Write the Template">
    Describe what to analyze — the image is automatically included as visual context.

    ```liquid theme={null}
    Analyze this product image and provide:
    - A detailed description
    - Up to 10 relevant tags
    - Dominant colors (hex values)
    - Suggested category

    {% if inputs.focus %}
    Pay special attention to: {{ inputs.focus }}
    {% endif %}
    ```

    <Warning>
      Image inputs are **not** available as Liquid template variables. You cannot use `{{ inputs.photo }}` — the image data is sent separately as visual context to the model.
    </Warning>
  </Step>

  <Step title="Test">
    Upload an image in the test runner and verify the structured output.
  </Step>
</Steps>

## Image Editing

Edit existing images by combining image inputs with image outputs.

<Steps>
  <Step title="Set Up the Endpoint">
    Create an endpoint with:

    * An **Image** input field (the reference image)
    * An **Image** output field (the edited result)
    * Optional text inputs for edit instructions
  </Step>

  <Step title="Create a Prompt">
    Select an image generation model (e.g., **gpt-image-1**) and write your edit instructions:

    ```liquid theme={null}
    {{ inputs.edit_instructions | default: "Enhance this image" }}
    ```
  </Step>

  <Step title="Test">
    Upload a reference image, provide edit instructions, and run the test.
  </Step>
</Steps>

<Note>
  When input images are present, Endprompt automatically routes to the provider's image editing API instead of the generation API.
</Note>

## Custom Parameters Reference

Image generation parameters are configured per-prompt via the **Custom Parameters** panel. These parameters are **model/provider-specific** — consult your provider's API documentation for supported values.

### Parameter Precedence

Parameters are applied in this order (later values override earlier ones):

1. **Hardcoded defaults** — Built-in sensible defaults
2. **Output Field Example Value** — JSON config set on the image output field
3. **Custom Parameters** — Per-prompt overrides from the Custom Parameters panel

### Common OpenAI Image Parameters

| Parameter    | Values                                | Description                   |
| ------------ | ------------------------------------- | ----------------------------- |
| `size`       | `1024x1024`, `1024x1536`, `1536x1024` | Output image dimensions       |
| `quality`    | `low`, `medium`, `high`, `auto`       | Generation quality level      |
| `n`          | `1` - `4`                             | Number of images to generate  |
| `background` | `auto`, `transparent`, `opaque`       | Background style (PNG output) |

<Warning>
  Other providers may support different parameters. For example, Anthropic and Google have their own image APIs with different options. Always check the provider's documentation.
</Warning>

## Pricing

Image generation models typically use different pricing than text models:

* **Per-token pricing**: Some models (gpt-image-1) charge based on input and output tokens, where image output tokens reflect resolution
* **Quality impact**: Higher quality settings produce more output tokens and cost more
* **Size impact**: Larger image dimensions increase output token usage

Check the **LLM Models** admin page for current per-model pricing.

## Limitations

* Maximum **16 input images** per request for editing workflows
* Supported input formats: **JPEG, PNG, WebP**
* Images are sent as base64 data URIs — very large images increase request size and latency
* Bulk CSV testing does **not** support image inputs
* Image generation responses don't include standard JSON output fields

## Next Steps

<CardGroup cols={2}>
  <Card title="Input Schema" icon="arrow-right-to-bracket" href="/endpoints/input-schema">
    Define image input fields
  </Card>

  <Card title="Output Schema" icon="arrow-right-from-bracket" href="/endpoints/output-schema">
    Configure image output fields
  </Card>

  <Card title="Custom Parameters" icon="sliders" href="/prompts/create-prompt">
    Set up generation parameters
  </Card>

  <Card title="Code Examples" icon="code" href="/api/code-examples">
    Image API integration examples
  </Card>
</CardGroup>
