Skip to main content

Official Python SDK for the CUBE AI Agent Marketplace

Project description

cube-ai-sdk

Python SDK for the CUBE AI Agent Marketplace.

Installation

pip install cube-ai-sdk

The importable module is cube_sdk:

from cube_sdk import CubeClient

Quick Start

from cube_sdk import CubeClient

client = CubeClient(api_key="cube_...", base_url="https://api.cube.bot")

Execute an agent

response = client.agents.execute("agent-id", query="Summarize this report")
print(response["answer"])
print(response["conversation_id"])  # use for multi-turn conversations

Multi-turn conversation

r1 = client.agents.execute("agent-id", query="What is CUBE?")
r2 = client.agents.execute(
    "agent-id",
    query="Tell me more",
    conversation_id=r1["conversation_id"],
)

Streaming

for event in client.agents.stream("agent-id", query="Write a poem"):
    if event["type"] == "token":
        print(event["content"], end="", flush=True)
print()

Agent specifications

specs = client.agents.specs("agent-id")
print(specs["llm_model"])
print(specs["skills"])

Environments

Three execution environments are supported:

  • "cube_cloud" (default) -- production on CUBE infrastructure
  • "sandbox" -- free testing with limited quotas
  • "byok" -- bring your own LLM key
response = client.agents.execute(
    "agent-id",
    query="Hello",
    environment="sandbox",
)

BYOK (Bring Your Own Key)

response = client.agents.execute(
    "agent-id",
    query="Hello",
    environment="byok",
    llm_api_key="sk-...",
)

Error Handling

from cube_sdk import CubeClient, AuthenticationError, RateLimitError, CubeAPIError

client = CubeClient(api_key="cube_...")

try:
    response = client.agents.execute("agent-id", query="Hello")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except CubeAPIError as e:
    print(f"API error {e.status_code}: {e.detail}")

Resource Management

# Context manager (recommended)
with CubeClient(api_key="cube_...") as client:
    response = client.agents.execute("agent-id", query="Hello")

# Manual cleanup
client = CubeClient(api_key="cube_...")
try:
    response = client.agents.execute("agent-id", query="Hello")
finally:
    client.close()

Marketplace Skills

CUBE agents can integrate with four marketplaces that use buyer-supplied credentials:

  • ozon -- Ozon seller: products, prices, stocks, orders, reviews, analytics
  • wildberries -- Wildberries seller: cards, prices, stocks, FBS orders, feedbacks, questions, sales
  • digiseller -- Plati.market / Digiseller: catalog, sales, buyer messages
  • yandex_direct -- Yandex Direct ads (per-user OAuth): campaigns, ads, negatives, async reports

Credentials aren't passed through the SDK -- buyers connect them once in Settings -> Marketplaces on their CUBE account and the platform injects them at runtime. Use client.agents.specs(id) and check specs["skills"] to detect which integrations an agent needs.

See the Marketplace Skills reference for per-action parameters and gotchas.

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

cube_ai_sdk-0.1.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

cube_ai_sdk-0.1.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file cube_ai_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: cube_ai_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cube_ai_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 796ed01e6cb7a8aea340131bbdba91ea91dc1394b1905437d7e952977c505a19
MD5 19455c75aef244542f237dcb87af4957
BLAKE2b-256 9b3ed94b3ae8e34f24ec9d70a15ef6f7b3b89ebcfa0cc790dce5105b123712c8

See more details on using hashes here.

File details

Details for the file cube_ai_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cube_ai_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for cube_ai_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44d209fbe299c9ad456b090cdabdbf090001df8d20a37124ebe056942a1082b4
MD5 7e1468c80e8771424ba7c963e2d2488e
BLAKE2b-256 c9a379c24e3d277864b8c69bc29b088734e1b7fbcc21e9509dbfa82c6fe39b1c

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