Search

3,380 results found for openai (5554ms)

Code
3,285

- 🎙️ Record voice notes directly in the browser
- 🤖 AI-powered transcription using OpenAI Whisper
- 🔗 Share voice notes via unique URLs
- ⏰ Set expiration by max listens or date
- **Database**: SQLite for voice note metadata
- **Storage**: Val Town Blob storage for audio files
- **AI**: OpenAI Whisper for transcription
- **Frontend**: React with TypeScript
- **Styling**: TailwindCSS
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: "Say hello in a creative way" },
const { messages, input, handleInputChange, handleSubmit, isLoading, setInput } = useChat({
api: "/api/chat",
// Tell AI SDK to expect OpenAI format
onError: (error) => {
console.error("Chat error:", error);
- ✅ AI Chat powered by custom agent
-**Robust streaming proxy** with proper format conversion and error handling
- ✅ Real-time streaming responses with proper OpenAI-compatible format
- ✅ Auto-scrolling to latest messages
- ✅ Enhanced loading indicators with animated dots
- **Centered layout** - Takes up 1/2 of screen width and full height
- **useChat hook** from Vercel AI SDK handles message state and streaming
- **Robust streaming proxy** - Properly converts agent's custom format to OpenAI-compatible SSE
- **Custom agent integration** - Seamlessly connects to your agent API with full error handling
- **Real-time streaming** - Word-by-word responses with proper buffering and parsing
The agent should return either:
`0:"content"`, `e:`/`d:` markers) which gets converted to OpenAI-compatible `text/event-stream`
- **Non-streaming**: JSON with `content`, `message`, or `choices[0].message.content`
- Properly parses the agent's custom streaming format line by line
- Handles incomplete chunks and buffering correctly
- Converts to OpenAI-compatible Server-Sent Events in real-time
- Provides graceful error handling and recovery
- Works seamlessly with the Vercel AI SDK
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: "Say hello in a creative way" },
Configure the following variables in your environment:
- `AGENT_API_KEY` (This is a secure token that you choose to secure the agent.tsx POST endpoint)
- `OPENAI_API_KEY` (An OpenAI API Key)
- `EXA_API_KEY` (Optional, though needed if you use the web search tool)
import { anthropic } from "npm:@ai-sdk/anthropic";
import { openai } from "npm:@ai-sdk/openai";
import { generateText, streamText } from "npm:ai";
import { getSystemPrompt } from "./prompt.tsx";
const maxSteps = 10;
ROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
const options = {
},
{
"title": "An Introduction to OpenAI fine-tuning",
"slug": "an-introduction-to-openai-fine-tuning",
"link": "/blog/an-introduction-to-openai-fine-tuning",
"description": "How to customize OpenAI to your liking",
"pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
"author": "Steve Krouse",
"link": "/blog/val-town-newsletter-16",
"description":
"Our seed round, growing team, Codeium completions, @std/openai, and more",
"pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
"author": "Steve Krouse",
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: "Say hello in a creative way" },
import { anthropic } from "npm:@ai-sdk/anthropic";
import { openai } from "npm:@ai-sdk/openai";
import { generateText, streamText } from "npm:ai";
import { getSystemPrompt } from "./prompt.tsx";
const maxSteps = 10;
const model = openai("gpt-4.1");
const options = {