Skip to content

OpenAI-compatible examples

CloudService works with the standard OpenAI SDK pattern. Set CLOUDSERVICE_BASE_URL to https://api.yourdomain.example/v1 for API credit or https://api.yourdomain.example/token/v1 for an API-token key. Choose an exact model ID returned by that key's authenticated catalog.

bash
# API-credit key:
export CLOUDSERVICE_BASE_URL="https://api.yourdomain.example/v1"
# API-token key:
# export CLOUDSERVICE_BASE_URL="https://api.yourdomain.example/token/v1"

SDK examples

Node SDK

bash
npm install openai
client.ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.CLOUDSERVICE_API_KEY,
  baseURL: process.env.CLOUDSERVICE_BASE_URL,
});

const completion = await client.chat.completions.create({
  model: "YOUR_AUTHENTICATED_MODEL_ID",
  messages: [{ role: "user", content: "Say hello from CloudService." }],
});

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

Client setup examples

For supported coding clients, the recommended setup is the globally installed cloudservice CLI. The snippets below document the manual fallback shape.

Codex

bash
# Recommended
npm install -g cloudservice
cloudservice

# Manual Codex provider config is documented at:
# https://docs.cloudservice.services/docs/manual-configuration/codex

Full per-client walkthroughs live in the manual configuration guides. For language-specific pages, see Python, JavaScript, and cURL; for the field-by-field contract, see OpenAI compatibility.