# Getting Started With the AI Stack for JavaScript

> a16z has released a JavaScript AI starter template that brings together Next.js, LangChain.js, Pinecone, Replicate, OpenAI, and Clerk. It helps developers build generative AI apps faster by handling authentication, hosting, and integration work out of the box.

- Source: https://www.waytoagi.com/en/kb/learning-path/javascript-ai-stack-getting-started
- Original (Feishu, Chinese): https://waytoagi.feishu.cn/wiki/F3mnwoXMAiJLAPkma42cTtoHnlh
- Updated: 2026-11-06

---

> Original link: https://a16z.com/2023/06/21/the-getting-started-with-ai-stack-for-javascript/
>
> Translation: WaytoAGI (Way to AGI). If there are any imperfections, please correct them in the paragraph comments. Many thanks.
>
> Published: June 21, 2023

It's hard to understand new software infrastructure technologies without using them. At least, that's what the a16z infrastructure team found — because many of us started our careers as programmers, we usually learn by doing. This is especially true in the generative AI wave, which arrived so fast and so spectacularly that good documentation often lags the code by months. So, to better understand this space, we built a few projects around large language models (LLMs), large image models, vector databases, and more.

Along the way, we noticed that because all of this is so new and changing so quickly, there's effectively no good framework for getting started quickly. Every project requires a lot of boilerplate code and integration. Frankly, it's a hassle. So we set out to create a very simple ["Getting Started with AI" template](https://github.com/a16z-infra/ai-getting-started) for people who want to experiment with the core technologies without having to think too much about ancillary concerns like licensing, hosting, and tooling choices.

You can fork and deploy the template [here](https://github.com/a16z-infra/ai-getting-started). We'd love to hear your thoughts and feedback to make the template better.

![](https://www.waytoagi.com/api/kb-media/O1USbXiR2ogmXexEOFmc2HfDnDH)


## Components

Many of us are JavaScript/TypeScript enthusiasts, so we chose the JavaScript stack as a starting point. However, the framework can easily be modified to support other programming languages, and we plan to do so soon.

Here's a brief overview of the getting-started stack we built together with our longtime partner and open-source enthusiast Tim Qian. Our goal was to highlight the simplest path from pulling code on GitHub to running a generative AI application (including images and text). It's designed to be easily extended to more complex architectures and projects:

- Authentication: [Clerk](https://clerk.com/) 

- Application logic: [Next.js](https://nextjs.org/) 

- Vector database: [Pinecone](https://www.pinecone.io/) / [Supabase pgvector](https://supabase.com/docs/guides/database/extensions/pgvector)

- LLM orchestration: [Langchain.js](https://js.langchain.com/docs/)

- Image models: [Replicate](https://replicate.com/) 

- Text models: [OpenAI](https://platform.openai.com/docs/models) 

- Deployment: [Fly.io](https://fly.io/) deployment

For a more detailed overview of the emerging LLM stack, check out our article titled "[Emerging Architectures for LLM Applications](https://ywh1bkansf.feishu.cn/wiki/QI6GwuqHSiEX8iktTs0cCJM1n8c)."


## Models and inference

Model hosting is a hassle and is largely a separate concern from building AI applications. So we use OpenAI for text models and Replicate for image inference. Replicate also offers text-based models (see how easy it is to run [Vicuna](https://replicate.com/replicate/vicuna-13b)), so you can use it as a substitute for OpenAI if needed.

![](https://www.waytoagi.com/api/kb-media/Oy38baGUKocoGQxR5uccUcCznlf)

[Example code](https://github.com/a16z-infra/ai-getting-started/blob/fc74d00552c7bdfdd504f98b0c7d362f8e5933c0/src/app/api/txt2img/route.ts) for running Stable Diffusion inference on Replicate

## Authentication

For a starter framework, we usually don't bother including authentication. But in this case, the model is so powerful and general-purpose that it becomes a target for large-scale organized efforts to gain free access. Developers often only find out the hard way when they receive an unexpected $10,000 bill from the model provider. That's why we chose to include Clerk, which can play an important role in bot detection and, of course, also provides full authentication support if you eventually build a more complex application.

![](https://www.waytoagi.com/api/kb-media/S2VRbrOO5omXNKxi0PYcUkhinrb)

[Example code](https://github.com/a16z-infra/ai-getting-started/blob/fc74d00552c7bdfdd504f98b0c7d362f8e5933c0/src/app/sign-up/%5B%5B...sign-up%5D%5D/page.tsx) for a drop-in Clerk component for user sign-up; this component handles bot detection, enforces 2FA, and detects user impersonation.


## Vector database

LLMs need stable long-term memory to preserve state and work around context window limitations, and this is handled by vector databases. Currently, Pinecone is the most mature and popular vector store among the generative AI community. That said, we want to support all use cases and preferences, so we've also included support for Supabase's [pg-vector](https://supabase.com/docs/guides/database/extensions/pgvector) in the repository.

![](https://www.waytoagi.com/api/kb-media/H2C3bhwV8ol4LFx1fXicqTm1nXe)

Example code for using Pinecone with Langchain.js. You can also find [examples](https://github.com/a16z-infra/ai-getting-started/blob/fc74d00552c7bdfdd504f98b0c7d362f8e5933c0/src/app/api/qa-pg-vector/route.ts) of using Supabase pg-vector [here](https://github.com/a16z-infra/ai-getting-started/blob/fc74d00552c7bdfdd504f98b0c7d362f8e5933c0/src/app/api/qa-pinecone/route.ts).


## Deployment

For deployment, we use Fly.io because it's multi-region, easy to manage, and provides a very general-purpose compute environment (anything that can run in a container). Over time, many AI projects end up using multiple programming languages and/or have non-trivial functionality in the backend, so Fly.io is a good compromise between JavaScript-native hosting environments (like Vercel or Netlify) and traditional cloud. That said, the code is also easy to support if you prefer a different hosting environment.

Fly.io will also soon offer GPUs for cases where you need to host your own models.


## Roadmap

Although we think this first version is a great starting point, we're gradually refining the stack and adding more options. Here's a glimpse of our roadmap:

- An interactive CLI for create-ai-stack, so developers can choose their own project scaffolding and dependencies.

- A transactional database for advanced use cases (e.g., persisting questions, user preferences, etc. in Q&A).

- More vector database and deployment platform options.

- A lightweight fine-tuning step for open-source models.

We'd love PRs with bug fixes, feature requests, and feedback. We're excited to contribute to the open-source community and believe the ecosystem will always benefit.

We're grateful to the following open-source projects that played an important role in creating our AI starter stack. These indispensable tools simplified complex tasks and made them easier to handle. It's through their tireless efforts and valuable contributions that the JavaScript ecosystem continues to thrive and flourish!

- [Tailwind](https://github.com/tailwindlabs/tailwindcss)

- [ai sdk](https://github.com/vercel-labs/ai)

- [dotenv](https://github.com/motdotla/dotenv)

- [Next.js](https://github.com/vercel/next.js/)

- [langchain.js](https://github.com/hwchase17/langchainjs)
