Official Python SDK for OSE Cloud Platform
Project description
OSE Cloud Python SDK
Official Python SDK for OSE Cloud - A powerful cloud platform for AI-powered development, sandboxes, and deployments.
Installation
pip install ose-cloud
Quick Start
from ose import OSE
# Initialize the client
client = OSE(api_key="your_api_key_here")
# Create a sandbox
sandbox = client.sandboxes.create(
name="my-sandbox",
template="python"
)
# Execute commands
result = sandbox.commands.run("python --version")
print(result.stdout)
# Work with files
sandbox.files.write("hello.py", "print('Hello, OSE Cloud!')")
content = sandbox.files.read("hello.py")
# Deploy an application
deployment = client.deployments.create(
name="my-app",
sandbox_id=sandbox.id,
port=3000
)
print(f"Deployed at: {deployment.url}")
Features
- Sandboxes: Create and manage isolated development environments
- Deployments: Deploy applications to production
- File Management: Read, write, and search files in sandboxes
- Command Execution: Run commands in sandbox environments
- Usage Tracking: Monitor your API usage and analytics
- Chat API: Interact with AI chat sessions
Documentation
Sandboxes
# Create a sandbox
sandbox = client.sandboxes.create(
name="my-project",
template="node",
envs={"NODE_ENV": "development"}
)
# List all sandboxes
sandboxes = client.sandboxes.list(status="active")
# Connect to existing sandbox
sandbox = client.sandboxes.connect("sandbox-id")
# Get sandbox info
info = sandbox.get_info()
# Delete sandbox
sandbox.delete()
File Operations
# Write a file
sandbox.files.write("index.js", "console.log('Hello World')")
# Write multiple files at once
sandbox.files.write_multiple([
{"path": "package.json", "content": "{}"},
{"path": "index.js", "content": "console.log('test')"}
])
# Read a file
content = sandbox.files.read("index.js")
# List files
files = sandbox.files.list("/")
# Search with glob
results = sandbox.files.glob("**/*.js")
# Search with grep
results = sandbox.files.grep(
pattern="console",
file_pattern="*.js",
case_sensitive=False
)
# Delete a file
sandbox.files.delete("index.js")
Command Execution
# Run a command
result = sandbox.commands.run(
command="npm install",
workdir="/workspace",
envs={"NODE_ENV": "production"}
)
print(f"Exit code: {result.exit_code}")
print(f"Output: {result.stdout}")
print(f"Errors: {result.stderr}")
Deployments
# Create a deployment
deployment = client.deployments.create(
name="my-app",
sandbox_id="sandbox-id",
port=3000,
build_command="npm run build",
start_command="npm start",
environment_variables={"API_KEY": "secret"}
)
# List deployments
deployments = client.deployments.list()
# Connect to existing deployment
deployment = client.deployments.connect("deployment-id")
# Get deployment info
info = deployment.get_info()
# View logs
logs = deployment.logs.get(lines=100)
# Restart deployment
deployment.restart()
# Stop deployment
deployment.stop()
# Delete deployment
deployment.delete()
Usage & Analytics
# Get usage statistics
usage = client.usage.get(range="7d") # "7d", "30d", or "all"
# Get analytics
analytics = client.usage.get_analytics(range="30d")
# List API keys
keys = client.usage.keys()
Chat API
# Create a chat
chat = client.chats.create(
title="My Chat Session",
visibility="private"
)
# Send a message
response = chat.send("Hello, how can I deploy a Next.js app?")
# Get chat messages
messages = chat.messages()
# List all chats
chats = client.chats.list()
# Connect to existing chat
chat = client.chats.connect("chat-id")
# Delete chat
chat.delete()
Error Handling
from ose import OSE, OSEError, APIError, AuthenticationError, NotFoundError
try:
client = OSE(api_key="your_api_key")
sandbox = client.sandboxes.create(name="test")
except AuthenticationError as e:
print("Invalid API key")
except NotFoundError as e:
print("Resource not found")
except APIError as e:
print(f"API error: {e.status_code} - {e.message}")
except OSEError as e:
print(f"SDK error: {e}")
Configuration
# Custom base URL and timeout
client = OSE(
api_key="your_api_key",
base_url="https://api.ose.cloud/v1",
timeout=120 # seconds
)
Requirements
- Python >= 3.8
- requests >= 2.28.0
Development
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black .
# Type checking
mypy ose
Links
Support
- Email: support@ose.cloud
- GitHub Issues: https://github.com/ose-cloud/sdk-python/issues
License
MIT License - see LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ose_cloud-1.0.0.tar.gz
(7.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ose_cloud-1.0.0.tar.gz.
File metadata
- Download URL: ose_cloud-1.0.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aa611ea40aa748cfea2ae104d3fdd94e4c1ebcd9661bcaf163da78948bfe65b
|
|
| MD5 |
eaafdbdfe5ef83c79c12ae26b939501f
|
|
| BLAKE2b-256 |
9c9163013f9b0cd7e6cad181f381cb4fd2e08645c1d53979819117a3e44b8f47
|
File details
Details for the file ose_cloud-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ose_cloud-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4de1f5ec5be0b2bf788d4cf2033c798ee9a09e01d4b3e3fd638ff0864af9829f
|
|
| MD5 |
bf0b796e76f54a0076d25539b8ba0722
|
|
| BLAKE2b-256 |
c980c98dac72e2acc89d35733f07ce934ab4c24fb77655d45830b59ae7ffd5db
|