Search

1,915 results found for β€œopenai”

Code
1,830

const INSTRUCTIONS = `
the user in English and tell them that they're using the OpenAI Realtime API, powered by the {{
Give them a very brief summary of the benefits of the Realtime API based on the details below,
// Verify the webhook.
const OPENAI_SIGNING_SECRET = Deno.env.get("OPENAI_SIGNING_SECRET");
if (!OPENAI_SIGNING_SECRET) {
console.error("πŸ”΄ webhook secret not configured");
}
const webhook = new Webhook(OPENAI_SIGNING_SECRET);
const bodyStr = await c.req.text();
**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP
(telephone) users. You can access the app via WebRTC at
If you remix the app, you'll just need to pop in your own `OPENAI_API_KEY` (from
[platform.openai.com](https://platform.openai.com)), and if you want SIP, the
`OPENAI_SIGNING_SECRET`.
- creates WebRTC offer
- `/rtc` endpoint handles SDP negotiation with OpenAI
- observer established to monitor session
const INSTRUCTIONS = `
Greet the user in English, and thank them for trying the new OpenAI Realtime API.
Give them a brief summary based on the list below, and then ask if they have any questions.
- improved handling of alphanumerics (eg, properly understanding credit card and phone numbers
- support for the OpenAI Prompts API
- support for MCP-based tools
const REALTIME_BASE_URL = "https://api.openai.com/v1/realtime";
const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
if (!OPENAI_API_KEY) {
throw new Error("πŸ”΄ OpenAI API key not configured");
}
const obj: Record<string, string> = {
Authorization: `Bearer ${OPENAI_API_KEY}`,
};
**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP
(telephone) users. You can access the app via WebRTC at
If you remix the app, you'll just need to pop in your own `OPENAI_API_KEY` (from
[platform.openai.com](https://platform.openai.com)), and if you want SIP, the
`OPENAI_SIGNING_SECRET`.
- creates WebRTC offer
- `/rtc` endpoint handles SDP negotiation with OpenAI
- observer established to monitor session
// Verify the webhook.
const OPENAI_SIGNING_SECRET = Deno.env.get("OPENAI_SIGNING_SECRET");
if (!OPENAI_SIGNING_SECRET) {
console.error("πŸ”΄ webhook secret not configured");
}
const webhook = new Webhook(OPENAI_SIGNING_SECRET);
const bodyStr = await c.req.text();
const REALTIME_BASE_URL = "https://api.openai.com/v1/realtime";
const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
if (!OPENAI_API_KEY) {
throw new Error("πŸ”΄ OpenAI API key not configured");
}
const obj: Record<string, string> = {
Authorization: `Bearer ${OPENAI_API_KEY}`,
};
* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it
* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.va
* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://
std/openai/README.md
23 matches
# OpenAI - [Docs β†—](https://docs.val.town/std/openai)
Use OpenAI's chat completion API with
[`std/openai`](https://www.val.town/v/std/openai). This integration enables
access to OpenAI's language models without needing to acquire API keys.
This SDK is powered by
[our openapiproxy](https://www.val.town/x/std/openaiproxy).
```ts title="Example" val
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
While our wrapper simplifies the integration of OpenAI, there are a few
limitations to keep in mind:
1. Create your own API key on
[OpenAI's website](https://platform.openai.com/api-keys)
2. Create an
[environment variable](https://www.val.town/settings/environment-variables?adding=true)
named `OPENAI_API_KEY`
3. Use the `OpenAI` client from `npm:openai`:
```ts title="Example" val
import { OpenAI } from "npm:openai";
const openai = new OpenAI();
```
com/val-town/val-town-docs/edit/main/src/content/docs/std/openai.mdx)
- `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)
- `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";
ROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
import { anthropic } from "npm:@ai-sdk/anthropic";
import { openai } from "npm:@ai-sdk/openai";
import { generateText, streamText } from "npm:ai";
ROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
std/openai/main.tsx
13 matches
import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
/**
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
*/
export class OpenAI {
private rawOpenAIClient: RawOpenAI;
/**
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
*
constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
this.rawOpenAIClient = new RawOpenAI({
...options,
baseURL: "https://std-openaiproxy.web.val.run/v1",
apiKey: Deno.env.get("valtown"),
get chat() {
return this.rawOpenAIClient.chat;
}
return {
chat: this.rawOpenAIClient.beta.chat,
};

Vals

79
View more
s
std
openai
Β 
Public
s
stevekrouse
openai_structured_output_demo
Β 
Public
openai-agents
templates
openai-agents
Template to use the OpenAI Agents SDK
Public
y
ynonp
translateToEnglishWithOpenAI
Β 
Public
m
maxm
openAIStreamingExample
Β 
Public
z
zzz
demoOpenAIGPT4Summary
Β 
Public
y
yawnxyz
openAiExample
Β 
Public
a
ashryanio
openAiProxy
Β 
Public
m
mjweaver01
OpenAIStreaming
Β 
Public
s
stevekrouse
openai
Β 
Public
s
stevekrouse
openaiUploadFile
Β 
Public
s
stevekrouse
openaistreaminghtml
Β 
Public
t
tmpmanueluhn65
openai-compatible-proxy
OpenAI-compatible API proxy with model mapping
Public
t
tmp100nuaa
openai-compatible-proxy
OpenAI-compatible API proxy using Val Town built-in AI models
Public
openai-agents
kidjs
openai-agents
Template to use the OpenAI Agents SDK
Public
…
8
…