AI SDK 5+/7 useChat({ api: '/api/chat' }) TypeScript error: 'api' does not exist in type UseChatOptions; use transport: new DefaultChatTransport({ api })
In @ai-sdk/react 4.x (AI SDK 7) the endpoint goes on a transport, not on useChat: useChat({ transport: new DefaultChatTransport({ api: '/api/custom-chat' }) }), with DefaultChatTransport imported from ai. UseChatOptions is now { chat } | ChatInit plus throttle/resume, and ChatInit takes transport, messages, onFinish, onError and so on. The old top-level api, body, headers and credentials options are gone, so v4 code like useChat({ api: '/api/chat' }) no longer type-checks. If your route really is /api/chat, you can drop the option: DefaultChatTransport defaults to api = "/api/chat". Headers, credentials, a custom fetch and prepareSendMessagesRequest (to reshape the request body) are all constructor options on DefaultChatTransport/HttpChatTransport. For a server that streams plain text (toTextStreamResponse), use TextStreamChatTransport instead; DefaultChatTransport expects the UI message stream. Checked against the ai 7.0.173 / @ai-sdk/react 4.0.177 type definitions.