# Usage Guide
## Load a schema from JSON text
```python
from ie_schema import IESchema
schema = IESchema.loads(
"""
{
"entities": ["gene", "disease"],
"relations": [
{"associated_with": {"head": "gene", "tail": "disease"}}
]
}
"""
)
```
## Load from a JSON Schema string
The same `IESchema.loads` accepts a **root JSON Schema** object as a string (for example from another tool or hand-written draft). Top-level keys must not match unknown IE ingest fields: native IE JSON rejects unknown top-level keys, so a document with `type` / `properties` is treated as JSON Schema, not as an empty IE schema.
```python
from ie_schema import IESchema
schema = IESchema.loads(
'{"type":"object","properties":{"title":{"type":"string"},"count":{"type":"integer"}}}'
)
```
## Load from dataclass or Pydantic model
`IESchema.loads` also accepts a stdlib dataclass / Pydantic v2 `BaseModel` class (or instance).
Install the optional dependency first:
```bash
uv add 'ie_schema[model]'
```
```python
from dataclasses import dataclass
from ie_schema import IESchema
@dataclass
class BusinessRecord:
business_name: str
score: float
schema = IESchema.loads(BusinessRecord)
```
## Load a schema from disk
```python
schema = IESchema.load("schema.json")
```
## Iterate planned tasks
`IESchema` is iterable and yields task objects for classification, entity extraction, relation extraction, and structure extraction.
```python
for task in schema:
print(type(task).__name__)
```
## Render prompt debug string
```python
print(schema.prompt())
```