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

# Input and Output Schemas

> Validate structured inputs and serialize endpoint results

Use `inputs` and `outputs` schemas to validate data on functions, endpoints, and task queues:

```python app.py theme={null}
from beam import endpoint, schema


class Inputs(schema.Schema):
    text = schema.String()
    repeat = schema.Integer()


class Outputs(schema.Schema):
    result = schema.String()


@endpoint(name="structured", inputs=Inputs, outputs=Outputs)
def handler(inputs):
    return {"result": inputs.text * inputs.repeat}
```

```bash theme={null}
beam deploy app.py:handler
```

Send `{"text": "hello", "repeat": 2}` to the endpoint. The handler receives a validated `Inputs` instance. You can also accept a [`context`](/v2/topics/context) argument.

## Field Types

| Field | Accepted value |
| - | - |
| `schema.String()` | String |
| `schema.Integer()` | Integer |
| `schema.JSON()` | JSON-compatible input; use an object or array for serialized outputs |
| `schema.Object(NestedSchema)` | Object validated against a nested schema |
| `schema.File()` | File-like object, URL, or base64 data |
| `schema.Image()` | Image data validated using Pillow |

All fields are required. Use `Schema.new(data)` to validate locally and `.dump()` to serialize. File outputs become [public URLs](/v2/data/output).

Install Pillow to use image fields. Custom validation methods and image-field limits are not preserved remotely; check those limits in your handler.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.