# build_chat_model

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/integrations/openai_codex/build_chat_model)

Construct a `_ChatOpenAICodex` model wired to the on-disk token store.

## Signature

```python
build_chat_model(
    model_name: str,
    /,
    *,
    store_path: Path | None = None,
    **kwargs: Any = {},
) -> BaseChatModel
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model_name` | `str` | Yes | Codex model identifier (e.g., `gpt-5.2-codex`). |
| `store_path` | `Path \| None` | No | Override the token store path. Defaults to `default_store_path()` so the model reads the same file that `get_status` / `run_browser_login` write. (default: `None`) |
| `**kwargs` | `Any` | No | Extra constructor kwargs forwarded to `_ChatOpenAICodex`. (default: `{}`) |

## Returns

`BaseChatModel`

A configured `_ChatOpenAICodex` instance, narrowed to `BaseChatModel`
so `create_model` can splice it into the standard return path.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/e14e0adcbe78565ed3650e7f24b2a775d5437d25/libs/code/deepagents_code/integrations/openai_codex.py#L500)