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 openaiclient.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);Python SDK
bash
pip install openaiclient.py
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["CLOUDSERVICE_API_KEY"],
base_url=os.environ["CLOUDSERVICE_BASE_URL"],
)
completion = client.chat.completions.create(
model="YOUR_AUTHENTICATED_MODEL_ID",
messages=[{"role": "user", "content": "Say hello from CloudService."}],
)
print(completion.choices[0].message.content)cURL
request.sh
export CLOUDSERVICE_AUTH_HEADER="Authorization: Bearer $CLOUDSERVICE_API_KEY"
curl "$CLOUDSERVICE_BASE_URL/chat/completions" -H "$CLOUDSERVICE_AUTH_HEADER" -H "Content-Type: application/json" -d '{
"model": "YOUR_AUTHENTICATED_MODEL_ID",
"messages": [{"role":"user","content":"Say hello from CloudService."}]
}'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/codexCursor
settings.json
{
"openai.baseURL": "YOUR_CLOUDSERVICE_BASE_URL",
"openai.apiKey": "your-scale-max-key"
}OpenCode
config.json
{
"client": "OpenCode",
"provider": "openai-compatible",
"baseURL": "YOUR_CLOUDSERVICE_BASE_URL",
"apiKey": "your-scale-max-key"
}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.