Python SDK
Set a custom base_url in the OpenAI Python SDK to connect to Xuo. First set your environment variables and prepare Python 3.9 or later.
1. Install
python -m pip install --upgrade openaiOn Windows, replace python with py if you use the Python launcher. Install into your project's virtual environment.
2. Connect and list models
Base URL: https://api.xuo.cc/v1.
Put this code in xuo_models.py. The key is read from the environment rather than stored in the script.
import os
from openai import OpenAI
with OpenAI(
api_key=os.environ["XUO_API_KEY"],
base_url="https://api.xuo.cc/v1",
timeout=60.0,
max_retries=0,
) as client:
for model in client.models.list():
print(model.id)python xuo_models.pySet XUO_MODEL to a listed model that supports Chat Completions.
3. Send a request
Put this code in xuo_chat.py:
import os
from openai import OpenAI
with OpenAI(
api_key=os.environ["XUO_API_KEY"],
base_url="https://api.xuo.cc/v1",
timeout=60.0,
max_retries=0,
) as client:
response = client.chat.completions.create(
model=os.environ["XUO_MODEL"],
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content or "")python xuo_chat.pyKeep max_retries=0 during initial setup to see the original error. For production retries, limit attempts and use backoff. A timeout does not prove that the server did not execute the request; retrying may consume additional credit.
Next steps
Streaming & troubleshooting · Responses example · Official SDK documentation
Chat Completions and Responses are different endpoints. Confirm model and channel support before choosing one.
