Skip to content

Instantly share code, notes, and snippets.

View kudoh's full-sized avatar
🥷
Focusing

noboru kudoh kudoh

🥷
Focusing
View GitHub Profile
@kudoh
kudoh / google-search.ts
Created October 9, 2024 09:22
OpenAI Realtime API with Function calling
import { customsearch } from '@googleapis/customsearch';
const API_KEY = process.env.CSE_API_KEY ?? '';
const ENGINE_ID = process.env.CSE_ENGINE_ID ?? '';
export async function webSearch({ query }: { query: string }) {
console.log('Web Search:', query);
const api = customsearch({
auth: API_KEY,
version: 'v1'
@kudoh
kudoh / realtimeapi-cli.ts
Last active July 23, 2025 20:29
OpenAI Realtime API Example
import WebSocket from 'ws';
import { spawn } from 'child_process';
const url = 'wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01';
const ws = new WebSocket(url, {
headers: {
'Authorization': 'Bearer ' + process.env.OPENAI_API_KEY,
'OpenAI-Beta': 'realtime=v1'
}
});