OpenPond
Back to Docs/OpenAI JavaScript quickstart

OpenAI JavaScript quickstart

List hosted models and make a chat completion with an OpenPond API key.

OpenAI JavaScript quickstart

Install the standard OpenAI JavaScript package in server-side code:

bash
npm install openai

Set OPENPOND_API_KEY in your server environment, then list the public catalog and make one request:

ts
import OpenAI from "openai"; const apiKey = process.env.OPENPOND_API_KEY?.trim(); if (!apiKey) throw new Error("OPENPOND_API_KEY is required"); const openai = new OpenAI({ apiKey, baseURL: "https://api.openpond.ai/opchat/v1", }); const models = await openai.models.list(); const model = models.data[0]?.id; if (!model) throw new Error("No hosted OpenPond models are available"); const completion = await openai.chat.completions.create({ model, messages: [{ role: "user", content: "Write one sentence about clean APIs." }], }); console.log(completion.choices[0]?.message.content);

Do not run this code in a browser. The API key must remain in server-side infrastructure.

Next: Model catalog.