UNPKG

universal-ai-sdk

Version:

A **unified AI SDK for Node.js/TypeScript** that lets you talk to **multiple AI providers (OpenAI, Anthropic/Claude, DeepSeek, etc.)** with **one simple API**. No need to learn multiple SDKs — just plug in your API key and go! 🚀

20 lines (17 loc) 507 B
import axios from "axios"; import { AIRequest, AIResponse } from "../types"; export async function openaiHandler(req: AIRequest): Promise<AIResponse> { const res = await axios.post( "https://api.openai.com/v1/chat/completions", { model: req.model, messages: req.messages, stream: false, }, { headers: { Authorization: `Bearer ${process.env.OPENAI_API_KEY}` } } ); return { text: res.data.choices[0].message.content, raw: res.data, }; }