Skip to main content

Python SDK for Sematryx - AI-powered optimization that explains itself

Project description

Sematryx Python SDK

Official Python SDK for Sematryx - AI-powered optimization that explains itself.

Installation

pip install sematryx

Quick Start

from sematryx import Sematryx

client = Sematryx(api_key="sk-your-api-key")

# Simple optimization
result = client.optimize(
    objective="minimize",
    variables=[
        {"name": "x", "bounds": (-5, 5)},
        {"name": "y", "bounds": (-5, 5)},
    ],
    objective_function="x**2 + y**2",
)

print(f"Solution: {result.solution}")  # {'x': 0.0, 'y': 0.0}
print(f"Explanation: {result.explanation}")

Features

  • Simple API - One function call to optimize
  • Explainable Results - Understand why the optimizer made its decisions
  • Audit Trails - Full traceability for regulated industries
  • Private Learning - Your optimizations improve over time
  • Domain Libraries - Pre-built for finance, healthcare, supply chain

CLI Usage

# Install
pip install sematryx

# Set API key
export sematryx_API_KEY=sk-your-api-key

# Run optimization
sematryx optimize "x**2 + y**2" --bounds '{"x": [-5, 5], "y": [-5, 5]}'

# Check usage
sematryx usage

Async Support

from sematryx import AsyncSematryx

async with AsyncSematryx(api_key="sk-...") as client:
    result = await client.optimize(
        objective="minimize",
        variables=[{"name": "x", "bounds": (-5, 5)}],
        objective_function="x**2",
    )

Portfolio Optimization

result = client.optimize_portfolio(
    assets=["AAPL", "GOOGL", "MSFT", "AMZN"],
    returns=[0.12, 0.10, 0.08, 0.15],
    covariance=[...],  # 4x4 covariance matrix
    target_return=0.10,
    max_position=0.4,
    explanation_level=3,
)

print(result.solution)  # {'AAPL': 0.25, 'GOOGL': 0.20, ...}
print(result.explanation)  # "Allocated to maximize Sharpe ratio..."

Private Learning Store

Your optimizations improve over time:

result = client.optimize(
    ...,
    learning={
        "read_from_private": True,   # Learn from your past optimizations
        "write_to_private": True,    # Store this result for future learning
    }
)

Documentation

Full documentation at sematryx.com/docs

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sematryx-0.1.2.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sematryx-0.1.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file sematryx-0.1.2.tar.gz.

File metadata

  • Download URL: sematryx-0.1.2.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for sematryx-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5c4df2e2bca151aad9edf86c7359b33df19885b9eab32b2363006377f4d39773
MD5 11c1b837bbc9990a06a84632887b05a2
BLAKE2b-256 fd5ffda9695c29fd11c2fde7eda5a81099ddeb76af8cea780de485a5b31f4571

See more details on using hashes here.

File details

Details for the file sematryx-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sematryx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for sematryx-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5fd67daa037448122ced78fa2d9baf9c1a18e44d8e9ae2892b43af232d6f1666
MD5 4cd08b77b08e80552c26a70c1095b2b7
BLAKE2b-256 3e8c6513a773883f4e4ae0da5c3ec988bf6962250751643df1138bb7cb6545ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page