Metadata-Version: 2.4
Name: cube-ai-sdk
Version: 0.1.3
Summary: Official Python SDK for the CUBE AI Agent Marketplace
Project-URL: Homepage, https://cube-market.com
Project-URL: Documentation, https://cube-market.com/docs
Project-URL: Repository, https://gitlab.com/AKnyaZP/CUBE
Project-URL: Issues, https://gitlab.com/AKnyaZP/CUBE/-/issues
Project-URL: Changelog, https://gitlab.com/AKnyaZP/CUBE/-/blob/main/sdk/python/CHANGELOG.md
Author-email: CUBE <team@cube-market.com>
Maintainer-email: CUBE <team@cube-market.com>
License: MIT License
        
        Copyright (c) 2026 Artem Knyazev and CUBE contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,ai,cube,llm,marketplace,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Description-Content-Type: text/markdown

# cube-ai-sdk

Python SDK for the CUBE AI Agent Marketplace.

## Installation

```bash
pip install cube-ai-sdk
```

The importable module is `cube_sdk`:

```python
from cube_sdk import CubeClient
```

## Quick Start

```python
from cube_sdk import CubeClient

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

### Execute an agent

```python
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

```python
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

```python
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

```python
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

```python
response = client.agents.execute(
    "agent-id",
    query="Hello",
    environment="sandbox",
)
```

### BYOK (Bring Your Own Key)

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

## Error Handling

```python
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

```python
# 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](https://github.com/cube-ai/docs/blob/main/marketplace-skills.md) for
per-action parameters and gotchas.
