Search

4,263 results found for openai (2639ms)

Code
4,154

import { Hono } from "https://esm.sh/hono@3";
import { sqlite } from "https://esm.town/v/std/sqlite";
import { OpenAI } from "https://esm.sh/openai";
import { renderToString } from "https://esm.sh/react-dom/server";
import React, { useEffect, useState } from "https://esm.sh/react";
const app = new Hono();
const openai = new OpenAI();
// --- DATABASE SCHEMA ---
// Logic: In a real app, we'd verify the user's token balance here.
const completion = await openai.chat.completions.create({
messages: [{
role: "system",
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" },
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" },
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 { OpenAI } from "https://esm.town/v/std/openai";
export interface TranslatorConfig {
onChunk: TranslationChunkCallback
): Promise<string> {
const openai = new OpenAI();
const messages = [
];
// Use OpenAI streaming API
const stream = await openai.chat.completions.create({
model: config.model,
messages,
config: TranslatorConfig
): Promise<string> {
const openai = new OpenAI();
const messages = [
];
const completion = await openai.chat.completions.create({
model: config.model,
messages,
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" },
* Public faucet analysis endpoint
* No authentication required - accessible to all users
* No database operations - only calls external OpenAI API
*/
export default async function(req: Request): Promise<Response> {
const __secrets = JSON.parse(req.headers.get('x-secrets') || '{}');
const OPENAI_API_KEY = __secrets['OPENAI_API_KEY'];
try {
const { image } = await req.json();
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${OPENAI_API_KEY}`,
'Content-Type': 'application/json',
},
}
const OPENAI_API_KEY = __secrets['OPENAI_API_KEY'];
if (!OPENAI_API_KEY) {
return Response.json({ error: 'OpenAI API key not configured. Please add your API key.' }, {
}
}
console.log('Analyzing faucet image with OpenAI Vision...');
const prompt = `You are a professional plumber and faucet repair expert. Analyze this image
Make the instructions specific to the identified faucet type. Be thorough and practical.`;
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${OPENAI_API_KEY}`,
'Content-Type': 'application/json',
},
if (!response.ok) {
const errorData = await response.text();
console.error('OpenAI API error:', errorData);
return Response.json({ error: 'Failed to analyze image. Please try again.' }, { status: 50
}
const data = await response.json();
console.log('OpenAI response received');
const content = data.choices[0]?.message?.content;
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" },
1. Click [**Remix**](/?intent=remix)
2. Add environment variables:
- `OPENAI_API_KEY` — for AI lead qualification
- `GITHUB_TOKEN` — for accessing GitHub API
([create one here](https://github.com/settings/tokens))

Vals

95
View more
peterqliu
PineconeIndex
Vector db's on Pinecone, with OpenAI embeddings
Public
openai-agents
stevekrouse
openai-agents
Template to use the OpenAI Agents SDK
Public
Ronsykes
hello-realtime
Sample app for the OpenAI Realtime API
Public
Ronsykes
hello-realtime-rs
Sample app for the OpenAI Realtime API
Public
dcm31
turso_events_estimator
Estimate OpenAI calls from Turso GitHub events
Public

Docs

11
View more
No docs found