Search

3,380 results found for openai (5922ms)

Code
3,285

```
### OpenAI Integration
```typescript
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" }],
model: "gpt-4o-mini",
<library>
## OpenAI
Val Town includes a free, proxied 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" },
```
OpenAI only works on the server. If the val includes client-side code, use dynamic imports t
`const { OpenAI } = await import "https://esm.town/v/std/openai");`
</library>
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 "npm: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" },
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 = {
svc/Cards/main.tsx
4 matches
export default async function server(request) {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
if (request.method === "POST" && new URL(request.url).pathname === "/grade-card") {
try {
const openai = new OpenAI();
const { frontImageBase64, backImageBase64 } = await request.json();
`;
const response = await openai.chat.completions.create({
model: modelChoice,
response_format: { type: "json_object" },
const jsonString = response.choices[0]?.message?.content;
if (!jsonString) {
throw new Error("OpenAI returned an empty response.");
}
import { OpenAI } from "https://esm.town/v/std/openai";
import { PDFExtract } from "npm:pdf.js-extract";
const action = url.searchParams.get("action");
const sourceUrl = `https://${url.hostname}${url.pathname}`;
const openai = new OpenAI();
const MAX_TEXT_ANALYZE = 30000;
const jsonResponse = (body: object, status: number) =>
async function callAI(prompt: string, userMessage: string, isJson: boolean = true) {
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "system", content: prompt }, { role: "user", content: userMessage }],
conversation.unshift(contextMessage);
}
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [systemMessage, ...conversation],
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 { END, MemorySaver, MessagesAnnotation, START, StateGraph } from "https://esm.sh/@langcha
import { ToolNode } from "https://esm.sh/@langchain/langgraph@0.3.3/prebuilt";
import { ChatOpenAI } from "https://esm.sh/@langchain/openai@0.5.11";
eLimitingTool } from "https://esm.town/v/cricks_unmixed4u/openai-client/langchain.tsx";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite?v=13";
// Initialize LangChain components
const chatModel = new ChatOpenAI({
modelName: "gpt-4o-mini",
temperature: 0.7,