#openai

12 snippets tagged with #openai

typescriptintermediate

OpenAI Chat Completion with Streaming

Stream GPT responses token-by-token using the OpenAI SDK with async iteration.

#openai#streaming
typescriptbeginner

Generate Text Embeddings with OpenAI

Create vector embeddings for semantic search and similarity matching using text-embedding-3-small.

#openai#embeddings
typescriptadvanced

RAG Pipeline (Retrieve + Augment + Generate)

Minimal RAG implementation: embed a query, retrieve top-k chunks, inject into prompt.

#rag#embeddings
typescriptintermediate

OpenAI Tool Calling (Function Calling)

Define tools for GPT to call, parse the response, execute the function, and return results.

#openai#tool-calling
pythonbeginner

LangChain Prompt Chain (Python)

Build a simple LLMChain with a prompt template and ChatOpenAI in LangChain.

#langchain#openai
typescriptbeginner

DALL·E 3 Image Generation

Generate images from a text prompt using the OpenAI DALL·E 3 API and return a URL.

#openai#dall-e
typescriptintermediate

OpenAI Structured Output with Zod

Force GPT-4o to return valid JSON matching a Zod schema using response_format structured output.

#openai#zod
typescriptbeginner

Content Moderation with OpenAI

Check user input for harmful content using the OpenAI Moderation API before processing.

#openai#moderation
typescriptintermediate

Next.js AI Streaming Route Handler

Stream OpenAI responses from a Next.js App Router route handler using the Vercel AI SDK.

#nextjs#openai
typescriptintermediate

OpenAI Assistants API with Threads

Create persistent conversation threads with OpenAI Assistants API for stateful multi-turn interactions.

#openai#assistants
pythonbeginner

Token Counter with Tiktoken

Count tokens and estimate costs for OpenAI API calls using the tiktoken tokenizer library.

#tokens#tiktoken
typescriptbeginner

OpenAI Text-to-Speech

Generate natural speech audio from text using OpenAI TTS API with multiple voice options and formats.

#tts#speech