Skip to content

Python Integration

Use WAYSCloud services from Python. The easiest way is with the official SDK:

bash
pip install wayscloud

You can also use standard libraries like requests, boto3, and the openai package directly — the examples below show both approaches.

Authentication

With requests (direct API)

python
import requests

API_KEY = "wayscloud_dns_abc123_yourkey"
BASE = "https://api.wayscloud.services/v1"

headers = {"X-API-Key": API_KEY}
# or: headers = {"Authorization": f"Bearer {API_KEY}"}

VPS Management

python
# List your servers
resp = requests.get(f"{BASE}/vps", headers=headers)
servers = resp.json()

# Create a VPS
resp = requests.post(f"{BASE}/vps", headers=headers, json={
    "plan_code": "vps-4gb-2cpu",
    "region": "NO",
    "os_template": "ubuntu-22.04",
    "ssh_keys": ["ssh-rsa AAAA..."],
    "display_name": "Web Server"
})
vps = resp.json()
print(f"VPS {vps['id']} at {vps['ipv4_address']}")

# Reboot
requests.post(f"{BASE}/vps/{vps['id']}/reboot", headers=headers)

See: Deploy a VPS | VPS API


Object Storage (boto3)

python
import boto3

s3 = boto3.client("s3",
    endpoint_url="https://storage.wayscloud.services",
    aws_access_key_id="wayscloud_s3_mybucket_abc123",
    aws_secret_access_key="your-secret-key"
)

# Upload a file
s3.upload_file("report.pdf", "my-bucket", "reports/2025/report.pdf")

# List objects
response = s3.list_objects_v2(Bucket="my-bucket", Prefix="reports/")
for obj in response.get("Contents", []):
    print(obj["Key"], obj["Size"])

# Generate a presigned URL (1 hour)
url = s3.generate_presigned_url("get_object",
    Params={"Bucket": "my-bucket", "Key": "reports/2025/report.pdf"},
    ExpiresIn=3600
)

See: Store Files | Storage API


LLM (OpenAI SDK)

The WAYSCloud LLM API is OpenAI-compatible:

python
from openai import OpenAI

client = OpenAI(
    api_key="wayscloud_api_abc123_yourkey",
    base_url="https://api.wayscloud.services/v1/llm"
)

# Chat completion
response = client.chat.completions.create(
    model="qwen3-235b-thinking",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Summarize this meeting transcript..."}
    ],
    max_tokens=1000,
    temperature=0.7
)

print(response.choices[0].message.content)
print(f"Tokens used: {response.usage.total_tokens}")

See: Run an LLM Request | LLM API


SMS

python
# Send an SMS
resp = requests.post(f"{BASE}/dashboard/sms/send",
    headers={"Authorization": f"Bearer {JWT_TOKEN}"},
    json={
        "to": ["+4799999999"],
        "message": "Your order has shipped."
    }
)
print(resp.json()["sms_message_id"])

See: Send an SMS | SMS API


Verify (OTP)

python
VERIFY_KEY = "wayscloud_verify_abc123_yourkey"
verify_headers = {"X-API-Key": VERIFY_KEY}

# Send verification code
resp = requests.post(f"{BASE}/verify/send",
    headers=verify_headers,
    json={"to": "+4799999999", "channel": "sms"}
)
session_id = resp.json()["session_id"]

# Check code
user_code = input("Enter code: ")
check = requests.post(f"{BASE}/verify/check",
    headers=verify_headers,
    json={"session_id": session_id, "code": user_code}
)

if check.json()["status"] == "verified":
    print("Verified!")

See: Send OTP | Verify API


DNS

python
DNS_KEY = "wayscloud_dns_abc123_yourkey"
dns_headers = {"X-API-Key": DNS_KEY}

# Create a zone
requests.post(f"{BASE}/dns/zones", headers=dns_headers, json={
    "zone_name": "example.com",
    "type": "PRIMARY"
})

# Add an A record
requests.post(f"{BASE}/dns/zones/example.com/records", headers=dns_headers, json={
    "name": "www",
    "type": "A",
    "content": "203.0.113.42",
    "ttl": 3600
})

See: Create a DNS Zone | DNS API


Error handling

All WAYSCloud APIs return standard HTTP status codes:

python
resp = requests.post(f"{BASE}/vps", headers=headers, json={"hostname": "web-01.example.com", "plan_code": "vps-4gb-2cpu", "region": "NO", "os_template": "ubuntu-24.04"})

if resp.status_code == 201:
    print("Created:", resp.json())
elif resp.status_code == 422:
    print("Validation error:", resp.json()["detail"])
elif resp.status_code == 401:
    print("Invalid API key")
else:
    print(f"Error {resp.status_code}:", resp.text)

Next steps

WAYSCloud AS