💻
Develop track bonus

AI Code Snippet Library

8 production-ready TypeScript snippets covering the patterns you'll use in every AI project. Copy, adapt, and ship.

8 snippets
Streamingtypescript

Stream an LLM response (OpenAI)

Render tokens as they arrive instead of waiting for the full response. Essential for chatbot-style UX.

Docs ↗
Streamingtypescript

Stream an LLM response (Anthropic)

Same pattern using the Anthropic SDK — streams Claude's response token by token.

Docs ↗
Structured Outputtypescript

Structured output with Zod

Force the model to return typed JSON that matches your schema — no more parsing errors.

Docs ↗
RAGtypescript

Basic RAG with LangChain + OpenAI

Retrieval-Augmented Generation: load documents, embed them, then answer questions from your own data.

Docs ↗
Tool Usetypescript

Function / Tool calling

Let the model decide when to call your functions — the foundation of AI agents.

Docs ↗
Next.jstypescript

Next.js AI streaming API route

A complete Next.js App Router API route that streams an LLM response to the browser.

Docs ↗
Prompt Engineeringtypescript

Prompt template with system role

Structure prompts properly with a system role to control model behaviour and output format.

Docs ↗
Conversationtypescript

Simple in-memory conversation history

Maintain multi-turn conversation context without a database — great for prototypes.

Docs ↗

Before running: Install dependencies with npm install openai @anthropic-ai/sdk langchain @langchain/openai zod and set your API keys in a .env file.