Search

3,265 results found for openai (1321ms)

Code
3,170

# hello-realtime
**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP
(telephone) users. You can access the app via WebRTC at
[hello-realtime.val.run](https://hello-realtime.val.run), or via SIP by calling
server-side websocket interface.
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`.
## Architecture
- Browser connects to frontend
- creates WebRTC offer
- `/rtc` endpoint handles SDP negotiation with OpenAI
- observer established to monitor session
2. **SIP Flow**:
.trim();
const res = await fetch("https://text.pollinations.ai/openai", {
method: "POST",
headers: {
/* ───────────── tool definition ───────────── */
export const mongoQueryTool = {
/* -- schema sent to OpenAI (strict mode removed) -- */
schema: {
type: "function",
},
{
"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",
"slug": "val-town-newsletter-16",
"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",
- [**We at Val Town**](https://www.val.town/u/valdottown) made [door](https://www.val.town/x/val
- [**Joey Hiller**](https://www.val.town/u/jhiller) made [ValTown-Package-Tracker](https://www.v
//www.val.town/x/dinavinter/slack), a Slack bot that uses OpenAI to generate responses.
- [**prashamtrivedi**](https://www.val.town/u/prashamtrivedi) made [hn-remote-ts-genai-jobs](htt
- [**dcm31**](https://www.val.town/u/dcm31) made [rotrank](https://www.val.town/x/dcm31/rotrank)
_2 or_3) to create a fresh table.
### 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" },
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES ---
if (req.method === "POST" && action === "getProblem") {
try {
const openai = new OpenAI();
const body = await req.json();
const level = typeof body.level === "number" ? body.level : 1;
];
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: messages,
const content = completion.choices[0].message.content;
if (!content) {
throw new Error("OpenAI returned an empty response.");
}
const REALTIME_BASE_URL = "https://api.openai.com/v1/realtime";
const MODEL = "gpt-realtime";
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.
Answer questions using the information below. For questions outside this scope,
- higher audio quality
- improved handling of alphanumerics (eg, properly understanding credit card and phone numbers
- support for the OpenAI Prompts API
- support for MCP-based tools
- auto-truncation to reduce context size
};
const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
if (!OPENAI_API_KEY) {
throw new Error("🔴 OpenAI API key not configured");
}
export function makeHeaders(contentType?: string) {
const obj: Record<string, string> = {
Authorization: `Bearer ${OPENAI_API_KEY}`,
};
if (contentType) obj["Content-Type"] = contentType;
sip.post("/", async (c) => {
// Verify the webhook.
const OPENAI_SIGNING_SECRET = Deno.env.get("OPENAI_SIGNING_SECRET");
if (!OPENAI_SIGNING_SECRET) {
console.error("🔴 webhook secret not configured");
return c.text("Internal error", 500);
}
const webhook = new Webhook(OPENAI_SIGNING_SECRET);
const bodyStr = await c.req.text();
let callId: string | undefined;
# hello-realtime
**Hello Realtime** is a OpenAI Realtime app that supports both WebRTC and SIP
(telephone) users. You can access the app via WebRTC at
[hello-realtime.val.run](https://hello-realtime.val.run), or via SIP by calling 425-800-0042.
server-side websocket interface.
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_SE
## Architecture
- Browser connects to frontend
- creates WebRTC offer
- `/rtc` endpoint handles SDP negotiation with OpenAI
- observer established to monitor session
2. **SIP Flow**: