# `vllm_mlx.constrained.json_schema_processor`

``JSONSchemaLogitsProcessor`` — a ``mlx_lm``-compatible logits processor that masks the vocabulary so the model can only emit tokens forming a valid JSON value (optionally matching a JSON schema).

[View the complete module source at #L1-L924](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L1-L924).

## API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

::: vllm_mlx.constrained.json_schema_processor
    options:
      members:
        - logger
        - LMFormatEnforcerNotAvailableError
        - _parser_cache
        - _MAX_NONPROGRESS_WHITESPACE_CHARS
        - _JSON_WHITESPACE
        - _canonical_schema_key
        - _get_or_build_parser
        - is_available
        - _GENERIC_JSON_SCHEMA
        - _simplify_schema
        - _force_no_additional_properties
        - _inject_no_additional_props
        - _collect_property_names
        - _walk_properties
        - _complete_json_eos_logits
        - _eos_logits
        - _eos_logits_or_original
        - JSONSchemaLogitsProcessor
      filters: []
      show_if_no_docstring: true

## Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.LMFormatEnforcerNotAvailableError" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.LMFormatEnforcerNotAvailableError</code> · class</summary>

```python
vllm_mlx.constrained.json_schema_processor.LMFormatEnforcerNotAvailableError()
```

Raised when ``lm-format-enforcer`` is required but not installed.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Constructs: `vllm_mlx.constrained.json_schema_processor.LMFormatEnforcerNotAvailableError`

**Exceptions and behavior**

Class `LMFormatEnforcerNotAvailableError` derives from `RuntimeError` and declares 0 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L33-L34](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L33-L34).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._canonical_schema_key" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._canonical_schema_key</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._canonical_schema_key(schema: dict | None) -> str
```

Function `_canonical_schema_key` calls `json.dumps(schema, sort_keys=True, separators=(',', ':')).encode`, `json.dumps`, `hashlib.sha256(blob).hexdigest`, `hashlib.sha256`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `dict \| None` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `str`
- Direct return expressions: `'__none__'`; `hashlib.sha256(blob).hexdigest()`

**Exceptions and behavior**

Function `_canonical_schema_key` calls `json.dumps(schema, sort_keys=True, separators=(',', ':')).encode`, `json.dumps`, `hashlib.sha256(blob).hexdigest`, `hashlib.sha256`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L50-L54](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L50-L54).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._get_or_build_parser" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._get_or_build_parser</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._get_or_build_parser(schema: dict | None) -> tuple[dict, Any]
```

Return (parser_schema, JsonSchemaParser) for ``schema``, memoised.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `dict \| None` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `tuple[dict, Any]`
- Direct return expressions: `cached`; `(parser_schema, parser)`

**Exceptions and behavior**

Function `_get_or_build_parser` calls `_canonical_schema_key`, `_parser_cache.get`, `_simplify_schema`, `_force_no_additional_properties`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L57-L73](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L57-L73).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.is_available" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.is_available</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor.is_available() -> bool
```

Return ``True`` iff ``lm-format-enforcer`` is importable.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `bool`
- Direct return expressions: `False`; `True`

**Exceptions and behavior**

Function `is_available` has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L76-L82](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L76-L82).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._simplify_schema" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._simplify_schema</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._simplify_schema(schema: dict) -> dict
```

Pre-process a JSON Schema for ``lm-format-enforcer`` compatibility.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `dict` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `dict`
- Direct return expressions: `_resolve(schema)`

**Exceptions and behavior**

Function `_simplify_schema` calls `copy.deepcopy`, `definitions.update`, `schema.pop`, `set`; returns `_resolve(schema)`.
No direct `raise` statement appears in this definition.

[View source #L97-L207](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L97-L207).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._simplify_schema._resolve" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._simplify_schema._resolve</code> · nested function</summary>

```python
vllm_mlx.constrained.json_schema_processor._simplify_schema._resolve(node: Any, depth: int = 0) -> Any
```

Nested Function `_simplify_schema._resolve` calls `isinstance`, `ref.split`, `len`, `resolving.add`; has 3 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `node` | `Any` | `yes` | `none` | Required positional or keyword input. |
| `depth` | `int` | `no` | `0` | Optional positional or keyword input; defaults to `0`. |

**Returns**

- Type: `Any`
- Direct return expressions: `node`; `result`; `{}`

**Exceptions and behavior**

Nested Function `_simplify_schema._resolve` calls `isinstance`, `ref.split`, `len`, `resolving.add`; has 3 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L121-L205](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L121-L205).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._force_no_additional_properties" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._force_no_additional_properties</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._force_no_additional_properties(schema: dict) -> dict
```

Return a deep copy of *schema* with ``additionalProperties: false`` injected into every object-type sub-schema that declares ``properties``.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `dict` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `dict`
- Direct return expressions: `schema`

**Exceptions and behavior**

Function `_force_no_additional_properties` calls `copy.deepcopy`, `_inject_no_additional_props`; returns `schema`.
No direct `raise` statement appears in this definition.

[View source #L210-L224](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L210-L224).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._inject_no_additional_props" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._inject_no_additional_props</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._inject_no_additional_props(node: Any) -> None
```

Recursively inject ``additionalProperties: false`` into *node*.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `node` | `Any` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`
- Direct return expressions: `None`

**Exceptions and behavior**

Function `_inject_no_additional_props` calls `isinstance`, `node.values`, `_inject_no_additional_props`; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L227-L238](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L227-L238).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._collect_property_names" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._collect_property_names</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._collect_property_names(schema: dict | None) -> set[str]
```

Collect all property names declared anywhere in *schema*.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `dict \| None` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `set[str]`
- Direct return expressions: `names`

**Exceptions and behavior**

Function `_collect_property_names` calls `set`, `_walk_properties`; returns `names`.
No direct `raise` statement appears in this definition.

[View source #L241-L247](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L241-L247).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._walk_properties" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._walk_properties</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._walk_properties(node: Any, names: set[str]) -> None
```

Function `_walk_properties` calls `isinstance`, `node.get`, `names.update`, `props.keys`; returns `None`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `node` | `Any` | `yes` | `none` | Required positional or keyword input. |
| `names` | `set[str]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`
- Direct return expressions: `None`

**Exceptions and behavior**

Function `_walk_properties` calls `isinstance`, `node.get`, `names.update`, `props.keys`; returns `None`.
No direct `raise` statement appears in this definition.

[View source #L250-L264](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L250-L264).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._complete_json_eos_logits" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._complete_json_eos_logits</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._complete_json_eos_logits(eos_set: set[int], suffix: list[int], logits: mx.array, is_complete_json, build_allow_mask) -> mx.array | None
```

Function `_complete_json_eos_logits` calls `is_complete_json`, `_eos_logits`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `eos_set` | `set[int]` | `yes` | `none` | Required positional or keyword input. |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |
| `logits` | `mx.array` | `yes` | `none` | Required positional or keyword input. |
| `is_complete_json` | `not annotated` | `yes` | `none` | Required positional or keyword input. |
| `build_allow_mask` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `mx.array | None`
- Direct return expressions: `None`; `_eos_logits(eos_set, logits, build_allow_mask)`

**Exceptions and behavior**

Function `_complete_json_eos_logits` calls `is_complete_json`, `_eos_logits`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L267-L276](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L267-L276).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._eos_logits" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._eos_logits</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._eos_logits(eos_set: set[int], logits: mx.array, build_allow_mask) -> mx.array | None
```

Function `_eos_logits` calls `build_allow_mask`, `sorted`; has 2 explicit return paths.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `eos_set` | `set[int]` | `yes` | `none` | Required positional or keyword input. |
| `logits` | `mx.array` | `yes` | `none` | Required positional or keyword input. |
| `build_allow_mask` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `mx.array | None`
- Direct return expressions: `None`; `logits + mask`

**Exceptions and behavior**

Function `_eos_logits` calls `build_allow_mask`, `sorted`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L279-L290](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L279-L290).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor._eos_logits_or_original" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor._eos_logits_or_original</code> · function</summary>

```python
vllm_mlx.constrained.json_schema_processor._eos_logits_or_original(eos_set: set[int], logits: mx.array, build_allow_mask) -> mx.array
```

Function `_eos_logits_or_original` calls `_eos_logits`; returns `logits if masked is None else masked`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `eos_set` | `set[int]` | `yes` | `none` | Required positional or keyword input. |
| `logits` | `mx.array` | `yes` | `none` | Required positional or keyword input. |
| `build_allow_mask` | `not annotated` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `mx.array`
- Direct return expressions: `logits if masked is None else masked`

**Exceptions and behavior**

Function `_eos_logits_or_original` calls `_eos_logits`; returns `logits if masked is None else masked`.
No direct `raise` statement appears in this definition.

[View source #L293-L299](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L293-L299).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor</code> · class</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor(schema: dict | None, tokenizer: Any)
```

Logits processor that constrains generation to valid JSON.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `dict \| None` | `yes` | `none` | Required positional or keyword input. |
| `tokenizer` | `Any` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Constructs: `vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor`

**Exceptions and behavior**

Class `JSONSchemaLogitsProcessor` declares 15 direct member(s).
No direct `raise` statement appears in this definition.

[View source #L302-L924](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L302-L924).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__init__" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__init__</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__init__(schema: dict | None, tokenizer: Any) -> None
```

Method `JSONSchemaLogitsProcessor.__init__` updates `self._tokenizer`, `self._schema`, `self._tok_data`, `self._disabled`; calls `is_available`, `LMFormatEnforcerNotAvailableError`, `get_tokenizer_data`, `_get_or_build_parser`; can raise `LMFormatEnforcerNotAvailableError`.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `schema` | `dict \| None` | `yes` | `none` | Required positional or keyword input. |
| `tokenizer` | `Any` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `None`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor.__init__` updates `self._tokenizer`, `self._schema`, `self._tok_data`, `self._disabled`; calls `is_available`, `LMFormatEnforcerNotAvailableError`, `get_tokenizer_data`, `_get_or_build_parser`; can raise `LMFormatEnforcerNotAvailableError`.
Directly raised exceptions: `LMFormatEnforcerNotAvailableError`.

[View source #L317-L414](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L317-L414).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix(tokens_list: list[int]) -> list[int]
```

Return the slice of ``tokens`` that corresponds to generated output.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tokens_list` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `list[int]`
- Direct return expressions: `tokens_list[self._prompt_len:]`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._suffix` updates `self._prompt_len`; calls `len`; returns `tokens_list[self._prompt_len:]`.
No direct `raise` statement appears in this definition.

[View source #L418-L426](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L418-L426).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_token_cached" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_token_cached</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_token_cached(tok_id: int) -> str | None
```

Return the decoded text for a single token (cached).

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tok_id` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `str | None`
- Direct return expressions: `cached`; `None`; `result`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._decode_token_cached` calls `self._token_decode_cache.get`, `self._tokenizer.decode`, `isinstance`; has 3 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L428-L442](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L428-L442).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_suffix" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_suffix</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_suffix(suffix: list[int]) -> str | None
```

Decode suffix tokens to text.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `str | None`
- Direct return expressions: `''`; `self._cached_suffix_text`; `None`; `result`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._decode_suffix` updates `self._cached_suffix_text`, `self._cached_suffix_len`, `self._json_ctx_scanned_len`, `self._json_ctx_in_string`; calls `len`, `self._tokenizer.decode`, `list`, `isinstance`; has 4 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L444-L493](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L444-L493).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix_is_complete_json" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix_is_complete_json</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix_is_complete_json(suffix: list[int]) -> bool
```

Return True if the decoded ``suffix`` parses as a complete JSON value.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `False`; `True`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._suffix_is_complete_json` calls `self._decode_suffix`, `text.strip`, `json.loads`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L495-L520](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L495-L520).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._get_json_context" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._get_json_context</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._get_json_context(suffix: list[int]) -> str
```

Determine the JSON structural context of the current suffix.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `str`
- Direct return expressions: `'other'`; `'in_key'`; `'key_start'`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._get_json_context` updates `self._json_ctx_in_string`, `self._json_ctx_last_quote_pos`, `self._json_ctx_scanned_len`, `self._brace_depth`; calls `self._decode_suffix`, `len`, `container_stack.append`, `container_stack.pop`; has 3 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L522-L643](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L522-L643).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_at_key_context" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_at_key_context</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_at_key_context(context: str, suffix: list[int], allowed: list[int]) -> list[int]
```

Apply schema-aware filtering when in key-related context.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `context` | `str` | `yes` | `none` | Required positional or keyword input. |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |
| `allowed` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `list[int]`
- Direct return expressions: `allowed`; `self._filter_key_start_tokens(suffix, allowed)`; `self._filter_in_key_tokens(suffix, allowed)`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._filter_at_key_context` calls `self._filter_key_start_tokens`, `self._filter_in_key_tokens`; has 3 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L645-L662](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L645-L662).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_key_start_tokens" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_key_start_tokens</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_key_start_tokens(suffix: list[int], allowed: list[int]) -> list[int]
```

Filter tokens at key-start position.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |
| `allowed` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `list[int]`
- Direct return expressions: `result if result else allowed`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._filter_key_start_tokens` calls `self._decode_token_cached`, `result.append`, `tok_text.lstrip`, `rest.find`; returns `result if result else allowed`.
No direct `raise` statement appears in this definition.

[View source #L664-L717](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L664-L717).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_in_key_tokens" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_in_key_tokens</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_in_key_tokens(suffix: list[int], allowed: list[int]) -> list[int]
```

Filter tokens when we're inside an open key string.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |
| `allowed` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `list[int]`
- Direct return expressions: `allowed`; `result if result else allowed`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._filter_in_key_tokens` calls `self._decode_suffix`, `text.rfind`, `self._decode_token_cached`, `result.append`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L719-L758](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L719-L758).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._is_valid_key_prefix" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._is_valid_key_prefix</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._is_valid_key_prefix(prefix: str) -> bool
```

Return True if *prefix* is a prefix of at least one valid key name.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `prefix` | `str` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `bool`
- Direct return expressions: `any((name.startswith(prefix) for name in self._valid_key_names))`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._is_valid_key_prefix` calls `any`, `name.startswith`; returns `any((name.startswith(prefix) for name in self._valid_key_names))`.
No direct `raise` statement appears in this definition.

[View source #L760-L762](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L760-L762).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_nonprogress_whitespace_tokens" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_nonprogress_whitespace_tokens</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_nonprogress_whitespace_tokens(suffix: list[int], allowed: list[int]) -> list[int]
```

Stop constrained JSON from spending a long run on pure whitespace.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suffix` | `list[int]` | `yes` | `none` | Required positional or keyword input. |
| `allowed` | `list[int]` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `list[int]`
- Direct return expressions: `allowed`; `filtered if filtered else allowed`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._filter_nonprogress_whitespace_tokens` calls `self._decode_suffix`, `len`, `text.rstrip`, `self._decode_token_cached`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L764-L793](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L764-L793).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._build_allow_mask" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._build_allow_mask</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._build_allow_mask(allowed: list[int], vocab_size: int) -> mx.array
```

Build a 1-D mask of length ``vocab_size`` where allowed positions are ``0`` and disallowed positions are ``-inf``.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `allowed` | `list[int]` | `yes` | `none` | Required positional or keyword input. |
| `vocab_size` | `int` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `mx.array`
- Direct return expressions: `mx.full((vocab_size,), -float('inf'))`; `mx.array(buf)`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor._build_allow_mask` calls `mx.full`, `float`, `np.full`, `mx.array`; has 2 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L795-L810](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L795-L810).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__call__" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__call__</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__call__(tokens: mx.array, logits: mx.array) -> mx.array
```

Apply the allowed-tokens mask to ``logits``.

**Parameters**

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tokens` | `mx.array` | `yes` | `none` | Required positional or keyword input. |
| `logits` | `mx.array` | `yes` | `none` | Required positional or keyword input. |

**Returns**

- Type: `mx.array`
- Direct return expressions: `_eos_logits_or_original(self._eos_set, logits, self._build_allow_mask)`; `eos_logits`; `logits`; `logits + mask`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor.__call__` updates `self._disabled`; calls `_eos_logits_or_original`, `hasattr`, `tokens.tolist`, `list`; has 4 explicit return paths.
No direct `raise` statement appears in this definition.

[View source #L814-L910](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L814-L910).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.schema" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.schema</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.schema() -> dict | None
```

Return the normalized JSON Schema enforced for this request.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `dict | None`
- Direct return expressions: `self._schema`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor.schema` returns `self._schema`.
No direct `raise` statement appears in this definition.

[View source #L915-L918](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L915-L918).

</details>

<details class="api-contract" id="contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.vocab_size" markdown="1">
<summary><code>vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.vocab_size</code> · method</summary>

```python
vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.vocab_size() -> int
```

Return the tokenizer vocabulary size used to construct masks.

**Parameters**

This callable has no explicit inputs.

**Returns**

- Type: `int`
- Direct return expressions: `self._vocab_size`

**Exceptions and behavior**

Method `JSONSchemaLogitsProcessor.vocab_size` returns `self._vocab_size`.
No direct `raise` statement appears in this definition.

[View source #L921-L924](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L921-L924).

</details>

## Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

| Symbol | Kind | Signature and inputs | What it does | Source |
| --- | --- | --- | --- | --- |
| [`LMFormatEnforcerNotAvailableError`](#contract-vllm_mlx.constrained.json_schema_processor.LMFormatEnforcerNotAvailableError) | class | `LMFormatEnforcerNotAvailableError()` | Raised when ``lm-format-enforcer`` is required but not installed. | [#L33-L34](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L33-L34) |
| [`_canonical_schema_key`](#contract-vllm_mlx.constrained.json_schema_processor._canonical_schema_key) | function | `_canonical_schema_key(schema: dict \| None) -> str` | Function `_canonical_schema_key` calls `json.dumps(schema, sort_keys=True, separators=(',', ':')).encode`, `json.dumps`, `hashlib.sha256(blob).hexdigest`, `hashlib.sha256`; has 2 explicit return paths. | [#L50-L54](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L50-L54) |
| [`_get_or_build_parser`](#contract-vllm_mlx.constrained.json_schema_processor._get_or_build_parser) | function | `_get_or_build_parser(schema: dict \| None) -> tuple[dict, Any]` | Return (parser_schema, JsonSchemaParser) for ``schema``, memoised. | [#L57-L73](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L57-L73) |
| [`is_available`](#contract-vllm_mlx.constrained.json_schema_processor.is_available) | function | `is_available() -> bool` | Return ``True`` iff ``lm-format-enforcer`` is importable. | [#L76-L82](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L76-L82) |
| [`_simplify_schema`](#contract-vllm_mlx.constrained.json_schema_processor._simplify_schema) | function | `_simplify_schema(schema: dict) -> dict` | Pre-process a JSON Schema for ``lm-format-enforcer`` compatibility. | [#L97-L207](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L97-L207) |
| [`_simplify_schema._resolve`](#contract-vllm_mlx.constrained.json_schema_processor._simplify_schema._resolve) | nested function | `_simplify_schema._resolve(node: Any, depth: int = 0) -> Any` | Nested Function `_simplify_schema._resolve` calls `isinstance`, `ref.split`, `len`, `resolving.add`; has 3 explicit return paths. | [#L121-L205](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L121-L205) |
| [`_force_no_additional_properties`](#contract-vllm_mlx.constrained.json_schema_processor._force_no_additional_properties) | function | `_force_no_additional_properties(schema: dict) -> dict` | Return a deep copy of *schema* with ``additionalProperties: false`` injected into every object-type sub-schema that declares ``properties``. | [#L210-L224](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L210-L224) |
| [`_inject_no_additional_props`](#contract-vllm_mlx.constrained.json_schema_processor._inject_no_additional_props) | function | `_inject_no_additional_props(node: Any) -> None` | Recursively inject ``additionalProperties: false`` into *node*. | [#L227-L238](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L227-L238) |
| [`_collect_property_names`](#contract-vllm_mlx.constrained.json_schema_processor._collect_property_names) | function | `_collect_property_names(schema: dict \| None) -> set[str]` | Collect all property names declared anywhere in *schema*. | [#L241-L247](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L241-L247) |
| [`_walk_properties`](#contract-vllm_mlx.constrained.json_schema_processor._walk_properties) | function | `_walk_properties(node: Any, names: set[str]) -> None` | Function `_walk_properties` calls `isinstance`, `node.get`, `names.update`, `props.keys`; returns `None`. | [#L250-L264](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L250-L264) |
| [`_complete_json_eos_logits`](#contract-vllm_mlx.constrained.json_schema_processor._complete_json_eos_logits) | function | `_complete_json_eos_logits(eos_set: set[int], suffix: list[int], logits: mx.array, is_complete_json, build_allow_mask) -> mx.array \| None` | Function `_complete_json_eos_logits` calls `is_complete_json`, `_eos_logits`; has 2 explicit return paths. | [#L267-L276](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L267-L276) |
| [`_eos_logits`](#contract-vllm_mlx.constrained.json_schema_processor._eos_logits) | function | `_eos_logits(eos_set: set[int], logits: mx.array, build_allow_mask) -> mx.array \| None` | Function `_eos_logits` calls `build_allow_mask`, `sorted`; has 2 explicit return paths. | [#L279-L290](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L279-L290) |
| [`_eos_logits_or_original`](#contract-vllm_mlx.constrained.json_schema_processor._eos_logits_or_original) | function | `_eos_logits_or_original(eos_set: set[int], logits: mx.array, build_allow_mask) -> mx.array` | Function `_eos_logits_or_original` calls `_eos_logits`; returns `logits if masked is None else masked`. | [#L293-L299](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L293-L299) |
| [`JSONSchemaLogitsProcessor`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor) | class | `JSONSchemaLogitsProcessor(schema: dict \| None, tokenizer: Any)` | Logits processor that constrains generation to valid JSON. | [#L302-L924](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L302-L924) |
| [`JSONSchemaLogitsProcessor.__init__`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__init__) | method | `JSONSchemaLogitsProcessor.__init__(schema: dict \| None, tokenizer: Any) -> None` | Method `JSONSchemaLogitsProcessor.__init__` updates `self._tokenizer`, `self._schema`, `self._tok_data`, `self._disabled`; calls `is_available`, `LMFormatEnforcerNotAvailableError`, `get_tokenizer_data`, `_get_or_build_parser`; can raise `LMFormatEnforcerNotAvailableError`. | [#L317-L414](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L317-L414) |
| [`JSONSchemaLogitsProcessor._suffix`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix) | method | `JSONSchemaLogitsProcessor._suffix(tokens_list: list[int]) -> list[int]` | Return the slice of ``tokens`` that corresponds to generated output. | [#L418-L426](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L418-L426) |
| [`JSONSchemaLogitsProcessor._decode_token_cached`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_token_cached) | method | `JSONSchemaLogitsProcessor._decode_token_cached(tok_id: int) -> str \| None` | Return the decoded text for a single token (cached). | [#L428-L442](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L428-L442) |
| [`JSONSchemaLogitsProcessor._decode_suffix`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._decode_suffix) | method | `JSONSchemaLogitsProcessor._decode_suffix(suffix: list[int]) -> str \| None` | Decode suffix tokens to text. | [#L444-L493](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L444-L493) |
| [`JSONSchemaLogitsProcessor._suffix_is_complete_json`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._suffix_is_complete_json) | method | `JSONSchemaLogitsProcessor._suffix_is_complete_json(suffix: list[int]) -> bool` | Return True if the decoded ``suffix`` parses as a complete JSON value. | [#L495-L520](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L495-L520) |
| [`JSONSchemaLogitsProcessor._get_json_context`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._get_json_context) | method | `JSONSchemaLogitsProcessor._get_json_context(suffix: list[int]) -> str` | Determine the JSON structural context of the current suffix. | [#L522-L643](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L522-L643) |
| [`JSONSchemaLogitsProcessor._filter_at_key_context`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_at_key_context) | method | `JSONSchemaLogitsProcessor._filter_at_key_context(context: str, suffix: list[int], allowed: list[int]) -> list[int]` | Apply schema-aware filtering when in key-related context. | [#L645-L662](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L645-L662) |
| [`JSONSchemaLogitsProcessor._filter_key_start_tokens`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_key_start_tokens) | method | `JSONSchemaLogitsProcessor._filter_key_start_tokens(suffix: list[int], allowed: list[int]) -> list[int]` | Filter tokens at key-start position. | [#L664-L717](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L664-L717) |
| [`JSONSchemaLogitsProcessor._filter_in_key_tokens`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_in_key_tokens) | method | `JSONSchemaLogitsProcessor._filter_in_key_tokens(suffix: list[int], allowed: list[int]) -> list[int]` | Filter tokens when we're inside an open key string. | [#L719-L758](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L719-L758) |
| [`JSONSchemaLogitsProcessor._is_valid_key_prefix`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._is_valid_key_prefix) | method | `JSONSchemaLogitsProcessor._is_valid_key_prefix(prefix: str) -> bool` | Return True if *prefix* is a prefix of at least one valid key name. | [#L760-L762](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L760-L762) |
| [`JSONSchemaLogitsProcessor._filter_nonprogress_whitespace_tokens`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._filter_nonprogress_whitespace_tokens) | method | `JSONSchemaLogitsProcessor._filter_nonprogress_whitespace_tokens(suffix: list[int], allowed: list[int]) -> list[int]` | Stop constrained JSON from spending a long run on pure whitespace. | [#L764-L793](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L764-L793) |
| [`JSONSchemaLogitsProcessor._build_allow_mask`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor._build_allow_mask) | method | `JSONSchemaLogitsProcessor._build_allow_mask(allowed: list[int], vocab_size: int) -> mx.array` | Build a 1-D mask of length ``vocab_size`` where allowed positions are ``0`` and disallowed positions are ``-inf``. | [#L795-L810](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L795-L810) |
| [`JSONSchemaLogitsProcessor.__call__`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.__call__) | method | `JSONSchemaLogitsProcessor.__call__(tokens: mx.array, logits: mx.array) -> mx.array` | Apply the allowed-tokens mask to ``logits``. | [#L814-L910](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L814-L910) |
| [`JSONSchemaLogitsProcessor.schema`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.schema) | method | `JSONSchemaLogitsProcessor.schema() -> dict \| None` | Return the normalized JSON Schema enforced for this request. | [#L915-L918](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L915-L918) |
| [`JSONSchemaLogitsProcessor.vocab_size`](#contract-vllm_mlx.constrained.json_schema_processor.JSONSchemaLogitsProcessor.vocab_size) | method | `JSONSchemaLogitsProcessor.vocab_size() -> int` | Return the tokenizer vocabulary size used to construct masks. | [#L921-L924](https://github.com/waybarrios/vllm-mlx/blob/a69d47912bcb21d8fe04d48f75fa896b620ffcfa/vllm_mlx/constrained/json_schema_processor.py#L921-L924) |
