SDK

OpenAI Node SDK

Connect the official OpenAI Node SDK to uouo cloud and handle streaming and errors.

Install

npm install openai

Configure the client

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.UOUODUO_API_KEY,
  baseURL: "https://uouo.cloud/v1",
});

Chat

const response = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [
    { role: "system", content: "You are a concise production assistant." },
    { role: "user", content: "Write a customer support reply template." },
  ],
});

console.log(response.choices[0]?.message?.content);

Streaming

const stream = await client.chat.completions.create({
  model: "gpt-4o-mini",
  stream: true,
  messages: [{ role: "user", content: "Explain gateway routing step by step." }],
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Embeddings

const embeddings = await client.embeddings.create({
  model: "text-embedding-3-small",
  input: ["First paragraph", "Second paragraph"],
});

Production notes

  • Keep `UOUODUO_API_KEY` on the server; never ship it to browsers.
  • Use separate keys for dev, staging, and production.
  • Add timeouts and retries around streaming requests.
  • Use `/app/logs` and `/app/usage` as the billing source of truth.
OpenAI Node SDK · uouo cloud