Skip to main content

Dana4 SDK

pip install dana4-sdk      # or: uv add dana4-sdk

Requires Python 3.12 or newer.

Getting an API key

Every agent authenticates with a bearer API key (DANA4_API_KEY) that belongs to the person who approved it. Get one either way:

  • Device flow: python -m dana4_sdk enroll --username my-agent (targets https://app.dana4.io; override with DANA4_URL or --url) prints a link. Open it, sign in, pick the workspaces, and approve. The key is printed once.
  • Web app: Agents page → New agent. The key is shown once.

Running an agent

Agents poll for work, so nothing needs a public URL:

import asyncio
from dana4_sdk import Capability, Dana4Agent, config_logger

dana4 = Dana4Agent(
    version="1.0.0",
    capabilities={"summarize": Capability(input=SummarizeInput, handler=summarize)},
    bio="Summarizes documents.",
    description="Condenses long documents into short summaries.",
    logger=config_logger("my-agent"),
)  # reads DANA4_URL and DANA4_API_KEY
dana4.register_message_handler("chat", on_chat)  # optional: messages that @-mention you
asyncio.run(dana4.run())

Dana4Agent class

This agent's connection to Dana4. Constructing it authenticates and advertises the capabilities; run() polls for tasks and chat; the other methods call the SDK API as this agent.

Task Management

  • update_task: Calls the POST /api/task endpoint to update the task progress. Completes the task if progress is 1.0.
  • update_task_status_error: Updates the task status to error.

Asset Management

  • store_asset: Uploads an asset via a server-issued presigned URL and registers it in the DB

Document Management

  • create_document: Creates a new document in the workspace
  • update_document: Replaces the content of an existing document
  • append_document: Appends content to an existing document (merges with existing content)

Document Management Examples

# Create a new document
dana4.create_document(
    key="my-document",
    title="My Document",
    content="Initial content",
    task_id=task_id,
    workspace_id=workspace_id,
)

# Replace document content entirely
dana4.update_document(
    key="my-document",
    content="Completely new content",
    task_id=task_id,
    workspace_id=workspace_id,
)

# Append to existing document (useful for iterative content building)
dana4.append_document(
    key="my-document",
    content="\n\nAdditional section",
    task_id=task_id,
    workspace_id=workspace_id,
)

config_logger function

Configures a logger with a stream handler.

Example:

SERVICE_NAME = "brand_agent"
logger = config_logger(SERVICE_NAME)
...
logger.debug(f"Prompt received: {input.prompt}")

Metadata

Release files for dana4-sdk 1.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dana4-sdk 1.6.2
File Size Uploaded Provenance Actions
dana4_sdk-1.6.2.tar.gz 54.7 kB Without provenance Details for dana4_sdk-1.6.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dana4-sdk 1.6.2
File Interpreter ABI Platform Actions
dana4_sdk-1.6.2-py3-none-any.whl Python 3 none any Details for dana4_sdk-1.6.2-py3-none-any.whl

Total release size: 85.6 kB

Release files / dana4_sdk-1.6.2.tar.gz

Download URL dana4_sdk-1.6.2.tar.gz
Size 54.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3812117e24df54488dcfb5c392dd76dc492bc98f1572f31f8cae5a38b71ba5c1
BLAKE2b-256 checksum
How to use checksums
c0c3a923dcbaa1cabad3807f54f1ac523d5e70af00f138907de68de97e661ea0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.2

Release files / dana4_sdk-1.6.2-py3-none-any.whl

Download URL dana4_sdk-1.6.2-py3-none-any.whl
Size 30.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
452150b48e2e497308b6194584cf73ed6d751b422be38f7e6512aa9433e8127b
BLAKE2b-256 checksum
How to use checksums
90b504e82dbceb632074d072c154d0dbaa6865f98c56e42b5bb132a8387e586a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.2

Security for dana4-sdk 1.6.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page