Skip to main content
Prerequisite: Complete the Quickstart to get an access key. All requests go to https://gateway.ngrok.ai.
TanStack AI is a type-safe library for building AI applications with React, Solid, and other frameworks. It works with the ngrok AI Gateway through its OpenAI adapter.

Installation

Basic usage

Configure the OpenAI adapter to use your AI Gateway endpoint:

Streaming responses

TanStack AI is built for streaming. Process chunks as they arrive:

API route handler

Build API endpoints that stream responses:
app/api/chat/route.ts

Using different providers

The AI Gateway routes based on the model name. Use provider prefixes to target specific providers:

Model failover

To try another model when the first one fails, see Configure fallback models.

Tool calling

The AI Gateway supports function/tool calling:

Provider options

Pass provider-specific options for fine-grained control:

React integration

Use TanStack AI with React for building chat interfaces:
app/page.tsx

Environment variables

Set up your environment:
.env.local

Next steps