Python SDK
Use the official OpenAI Python SDK and set base_url to CloudService. Model IDs come from the models and pricing page, and every request field is listed in Chat Completions.
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. This is the OpenAI-compatible route; native Claude apps use their origin-only setup instead.
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"Install
bash
pip install openaiBasic chat
client.py
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["CLOUDSERVICE_API_KEY"],
base_url=os.environ["CLOUDSERVICE_BASE_URL"],
)
response = client.chat.completions.create(
model="YOUR_AUTHENTICATED_MODEL_ID",
messages=[{"role": "user", "content": "Write a haiku about fast inference."}],
)
print(response.choices[0].message.content)Streaming
stream.py
stream = client.chat.completions.create(
model="YOUR_AUTHENTICATED_MODEL_ID",
messages=[{"role": "user", "content": "Stream a short greeting."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)Server-sent-event framing and safe disconnect handling are covered in Streaming. The same flow in other languages: JavaScript, cURL.