# createChat



# Overview

Creates a chat runtime that automatically injects the `searchIndexStore` resolved by [withPeam](/docs/api-reference/next/with-peam). It pairs with the [route handler](/docs/api-reference/next/route) export.

## Type Definition

```ts
import type { ChatRuntimeOptions, DefaultChatRuntime } from 'peam/server';

export declare function createChat(options?: ChatRuntimeOptions): DefaultChatRuntime;
```

## Usage

```ts
import { createChat } from '@peam-ai/next/route';
import { openai } from '@ai-sdk/openai';

export const POST = createChat({
  model: openai('gpt-4o-mini'),
}).handler;
```

## Notes

* [withPeam](/docs/api-reference/next/with-peam) must run during build so `searchIndexStore` can be resolved.
* You can override `searchIndexStore` by passing it in `options`.


## Sitemap
[Overview of all docs pages](/sitemap.md)
