# Constraints API

Apply constraints to any SDV synthesizer.

## Constraints API

### add\_constraints

Use this function to add constraints to your synthesizer.

**Parameters**

* (required) `constraints`: A list of constraint objects or an auto-detected `ConstraintList` object to add to your synthesizer. You can supply [**auto-detected constraints**](/sdv/concepts/constraint-augmented-generation-cag/auto-detect-constraints.md), [**predefined constraints**](/sdv/concepts/constraint-augmented-generation-cag/predefined-constraints.md) or [**program your own constraints**](/sdv/concepts/constraint-augmented-generation-cag/program-your-own-constraint.md).

**Output** (None)

```python
synthesizer.add_constraints(
    constraints=[my_constraint]
)
```

### get\_constraints

Use this function to inspect all of the constraints your synthesizer contains.

**Parameters** None

**Output** A list of the constraint objects that you have supplied to your synthesizer

```python
synthesizer.get_constraints()
```

### get\_metadata

Adding constraints to your synthesizer may internally modify the metadata. Use this function to get the modified metadata after the constraints have been added.

**Parameters**

* `version`: The version of metadata to get. Supply `'modified'` to get the modified version of the metadata (after applying the constraints).

**Output** A Metadata object with the modified metadata

```python
modified_metadata = synthesizer.get_metadata(version='modified')
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sdv.dev/sdv/concepts/constraint-augmented-generation-cag/constraints-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
