Metadata-Version: 2.4
Name: dualeai
Version: 0.2.0
Summary: Async Python SDK for managed Duale AI Tasks and customer-hosted Tools
Author: Duale AI
License-Expression: Apache-2.0
Project-URL: Homepage, https://duale.ai
Project-URL: Documentation, https://duale.ai/en/docs/sdk
Project-URL: Repository, https://github.com/dualeai/dualeai-python.git
Project-URL: Release notes, https://github.com/dualeai/dualeai-python/releases
Project-URL: Issues, https://github.com/dualeai/dualeai-python/issues
Project-URL: Security, https://github.com/dualeai/dualeai-python/security/policy
Keywords: ai-agents,agent-sdk,dualeai,structured-output,tool-calling
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiofiles~=24.1.0
Requires-Dist: aiohttp~=3.13
Requires-Dist: cryptography~=46.0
Requires-Dist: hpke-http[aiohttp]~=4.0
Requires-Dist: aiojobs~=1.4
Requires-Dist: aiosqlite~=0.20
Requires-Dist: opentelemetry-api~=1.44
Requires-Dist: opentelemetry-exporter-otlp-proto-http~=1.44
Requires-Dist: opentelemetry-sdk~=1.44
Requires-Dist: pydantic-settings~=2.10
Requires-Dist: pydantic~=2.12
Requires-Dist: python-dotenv~=1.0
Requires-Dist: redis[hiredis]~=5.2
Requires-Dist: structlog~=25.3
Requires-Dist: tenacity~=9.0
Requires-Dist: typing-extensions~=4.12
Requires-Dist: uuid-utils~=0.11
Provides-Extra: telemetry
Requires-Dist: opentelemetry-instrumentation~=0.65b0; extra == "telemetry"
Requires-Dist: opentelemetry-instrumentation-aiohttp-client~=0.65b0; extra == "telemetry"
Requires-Dist: opentelemetry-instrumentation-redis~=0.65b0; extra == "telemetry"
Requires-Dist: opentelemetry-instrumentation-sqlite3~=0.65b0; extra == "telemetry"
Requires-Dist: opentelemetry-instrumentation-system-metrics~=0.65b0; extra == "telemetry"
Provides-Extra: dev
Requires-Dist: dualeai[telemetry]; extra == "dev"
Requires-Dist: aioboto3~=15.5; extra == "dev"
Requires-Dist: aioresponses~=0.7; extra == "dev"
Requires-Dist: freezegun~=1.5; extra == "dev"
Requires-Dist: moto[s3,server]~=5.1; extra == "dev"
Requires-Dist: hypothesis~=6.151; extra == "dev"
Requires-Dist: packaging~=24.2; extra == "dev"
Requires-Dist: psutil~=7.1; extra == "dev"
Requires-Dist: ty~=0.0; extra == "dev"
Requires-Dist: pytest-aiohttp~=1.1; extra == "dev"
Requires-Dist: pytest-socket~=0.7; extra == "dev"
Requires-Dist: pytest-asyncio~=1.3; extra == "dev"
Requires-Dist: pytest-codspeed~=4.3; extra == "dev"
Requires-Dist: pytest-cov~=7.1; extra == "dev"
Requires-Dist: pytest-repeat~=0.9; extra == "dev"
Requires-Dist: pytest-timeout~=2.4; extra == "dev"
Requires-Dist: pytest-xdist[psutil]~=3.8; extra == "dev"
Requires-Dist: pytest~=9.0; extra == "dev"
Requires-Dist: ruff~=0.16; extra == "dev"
Requires-Dist: toml~=0.10; extra == "dev"
Requires-Dist: trustme~=1.2; extra == "dev"
Requires-Dist: twine~=6.0; extra == "dev"
Requires-Dist: vulture~=2.14; extra == "dev"
Dynamic: license-file

# Duale AI Python SDK

Use `dualeai` to submit Tasks, validate results, and expose Python functions as Tools.
Duale AI runs the Tasks; your async Python application runs its registered Tools.

**Status:** Public preview. Interfaces can change before a stable release.

## Install

Use CPython 3.10 through 3.14 on Linux or macOS:

```bash
python -m pip install dualeai
```

## Run the first live Task

Ask your administrator for an API token and access to a configured model; the SDK creates neither.
Use synthetic, non-sensitive input: live requests can consume metered or limited service resources.
Set your provisioned token in the current shell:

```bash
export DUALEAI_TOKEN=dualeai_your_provisioned_token_here
```

<!-- Provisioning, model eligibility, and service usage are Platform
requirements, unproved in this SDK. -->

Save this as `quickstart.py`:

```python
import asyncio

from pydantic import BaseModel

from dualeai import ask, create_sdk


class SupportDecision(BaseModel):
    next_action: str
    reason: str


async def main() -> None:
    async with create_sdk() as sdk:
        response = await ask(
            instruction="Review this synthetic support case and return the next safe action.",
            res=SupportDecision,
            sdk=sdk,
        )
        print(response.task_id)
        decision = await response.model()
        print(decision.next_action)


asyncio.run(main())
```

Run `python quickstart.py`. A successful run prints the Task ID, then the validated `next_action`; values depend on the model.
`ask()` returns a response handle. `await response.model()` waits for the final Task result and validates it against
`SupportDecision`.

Before retrying a failure, use [Errors and reliability](https://duale.ai/en/docs/sdk/errors) to identify its cause.

<!-- Nothing executes this live quickstart or enforces its printed shape. -->

## Configuration

`DUALEAI_TOKEN` is required for live requests. Set the other values only when your workflow needs them:

| Setting | When to use it |
| --- | --- |
| `DUALEAI_ENDPOINT` | A different API environment; the default is `https://api.beta.duale.ai` |
| `DUALEAI_AGENT_ID` | Hosting Tools or uploading Task attachments |
| `DUALEAI_TENANT_ID` | Managing Libraries or uploading Task attachments |
| `DUALEAI_OBSERVABILITY__TOKEN` | Exporting telemetry, with a separate telemetry token |

Attachment uploads also accept `agent_id=` in place of `DUALEAI_AGENT_ID`.
`dualeai[telemetry]` adds automatic instrumentation; configuration is still required to enable it.
See the [configuration example](https://github.com/dualeai/dualeai-python/blob/main/.env.example) for all settings.

## Examples and next steps

The [examples guide](https://github.com/dualeai/dualeai-python/tree/main/examples) lists setup and permissions.
Arrange Dashboard cleanup before running document examples: they leave stored Libraries.

For application tests without a live connection, use the
[MockSDK reference](https://duale.ai/en/docs/sdk/reference#mocksdk).

## Integrate into an application

- **Results:** streamed text is a live view of the answer and can arrive out of order. Order it by `generation` and
  `sequence` as the [examples guide](https://github.com/dualeai/dualeai-python/blob/main/examples/README.md#order-and-replace-streamed-content)
  shows, and use `await response.model()` for the validated result.
- **Stopping:** cancelling `response.task` stops local observation. Use `await response.stop(reason)` to request a
  Platform Stop. The response confirms acceptance of the Stop request, not that the Task has stopped.
  A Stop without the permission is refused at once with `DualeAIAuthError`. A permitted Stop is accepted even when
  the Task has already ended or the Platform does not know it.
  Keep `response.task_id` for diagnosis; the SDK cannot reattach to a Task using only its saved ID.
- **Tools:** calls execute on Task streams opened by the same SDK instance that registered the functions. Protect
  side effects with durable duplicate detection and redact exception text with `error_transform`. The
  [inventory example](https://github.com/dualeai/dualeai-python/blob/main/examples/inventory_agent.py) demonstrates
  redaction and explains where your application must record side effects durably.
- **Logging and telemetry:** SDK initialization replaces the process's root logging handlers; cleanup does not restore
  them. Optional telemetry instrumentation also acts across the process. Coordinate these settings with your host
  application.

<!-- Saved-ID reattachment limits and process-global logging/telemetry behavior are source-inspection findings; nothing enforces them. Platform permissions and Library cleanup requirements belong to the service and are documented in examples/README.md. Out-of-order content arrival is Platform behavior; nothing in this SDK enforces it. Acceptance of a permitted Stop for an ended or unknown Task is Platform behavior; nothing in this SDK enforces it. -->

## Project links

- [SDK documentation](https://duale.ai/en/docs/sdk)
- [Release notes](https://github.com/dualeai/dualeai-python/releases)
- [Issues](https://github.com/dualeai/dualeai-python/issues)
- [Contributing](https://github.com/dualeai/dualeai-python/blob/main/CONTRIBUTING.md)
- [Security policy](https://github.com/dualeai/dualeai-python/security/policy) — report suspected vulnerabilities through
  the private routes there, not through a public issue
- [Apache-2.0 license](https://github.com/dualeai/dualeai-python/blob/main/LICENSE)
