Skip to main content

iq-sdk

A Python SDK for creating and managing distributed workers in IQ Flow orchestration platform.

PyPI version CI License: MIT

Quickstart

# Create project directory
mkdir my_iq_tools_project
cd my_iq_tools_project

# Set up virtual environment
python -m venv .venv
source .venv/bin/activate

# Install iq-sdk
pip install iq-sdk

# Initialize project
iq init .

This creates a complete project with configuration, Docker setup, GitHub Actions, and more.

Next steps:

# Set your password in .env
echo "IQ_SITE_DEFAULT_API_SECRET=secret" >> .env

# Create a tool
iq tool add hello

# Run the worker
iq worker run

→ Full Quickstart Guide

Features

  • Site-Based Configuration - Manage multiple sites with host/env/user/password
  • CLI for Project Scaffolding - Complete setup with iq init
  • Socket.IO Worker Connectivity - Workers connect to one or more sites
  • Secure Secrets Handling - Passwords via ENV or K8s-style file references
  • Configurable Threading - Set thread counts, enable autoscaling
  • Docker Integration - Built-in support for baker-cli

Project Structure

After iq init, you get:

my-project/
├── config/
│   └── settings.yml      # Sites and tool configuration
├── .env                  # Secrets (passwords)
├── .gitignore
├── pyproject.toml
├── build-settings.yml    # Docker build config
├── tools/                # Your tool implementations
├── .devcontainer/        # VS Code DevContainer
├── .github/workflows/    # GitHub Actions
└── docker/               # Dockerfile & compose

CLI Reference

Site Management

iq site ls                # List all sites
iq site ls --remote       # Check connectivity
iq site add prod --host http://prod:3000
iq site rm prod

Tool Management

iq tool add NAME          # Create a tool
iq tool ls                # List tools

Worker Management

iq worker ls              # Show configured tools/workers
iq worker ls --remote     # Check tool availability
iq worker run [OPTIONS]   # Start a worker

Options:
  --threads, -t INT      Thread count
  --max-threads INT      Max threads (autoscaling)
  --autoscale            Enable autoscaling
  --tool TOOL            Tools to register (repeatable)
  --site, -s SITE        Sites to connect (repeatable)
  --config, -c FILE      Config file

Output Queue

When task output submission fails (host unreachable, errors), outputs are queued locally for retry:

iq worker queue           # List pending outputs
iq worker queue --failed  # List failed (max retries exceeded)
iq worker queue -t tool   # Filter by tool name
iq worker queue --retry   # Manually retry all pending
iq worker queue --retry -y  # Retry without confirmation

Queue files are stored in ./data/{site}/queue-output/.

Configuration

Sites (config/settings.yml)

site:
  id: "default"
  host: "http://localhost:3000"
  api_key: "worker"
  tools:
    - "my-tool"

sites:
  - id: "production"
    host: "http://prod:3000"
    api_key: "prod-worker"
    tools:
      - "my-tool"

Secrets (.env)

# Direct password
IQ_SITE_DEFAULT_PASSWORD=secret
IQ_SITE_PRODUCTION_PASSWORD=prod-secret

# Or file reference (K8s/Docker secrets)
IQ_SITE_PRODUCTION_API_SECRET_FILE=/run/secrets/prod-password

# For JSON/YAML secrets, extract with _PASSWORD_KEY
IQ_SITE_STAGING_API_SECRET_FILE=/etc/secrets/creds.json
IQ_SITE_STAGING_API_SECRET_KEY=database.password

Worker Settings (config/settings.yml)

worker:
  threads: 2              # Default threads per tool
  autoscale: false        # Enable autoscaling
  min_threads: 1          # Min threads (autoscaling)
  max_threads: 16         # Max threads (autoscaling)

  # Retry settings for failed output submissions
  retry:
    max_retries: 10       # Max retry attempts before moving to failed queue
    initial_delay: 10     # Initial retry delay in seconds
    max_delay: 3600       # Maximum retry delay (1 hour)
    backoff_multiplier: 2.0  # Exponential backoff multiplier

Environment Override

export IQ_SITE_PRODUCTION_HOST='http://new-host:3000'
export IQ_WORKER__THREADS=8
export IQ_WORKER__RETRY__MAX_RETRIES=20

Documentation

Development

For contributing or local development:

git clone https://github.com/iq-company/iq-sdk.git
cd iq-sdk
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# Test your changes
iq init demo
cd demo

→ Development Guide

License

MIT License - see LICENSE for details.

Metadata

Release files for iq-sdk 0.4.0

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

Source distribution (sdist)

Source distribution for iq-sdk 0.4.0
File Size Uploaded
iq_sdk-0.4.0.tar.gz 149.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iq-sdk 0.4.0
File Interpreter ABI Platform
iq_sdk-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 291.7 kB

Release files / iq_sdk-0.4.0.tar.gz

Download URL iq_sdk-0.4.0.tar.gz
Size 149.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8944505c2145d8572f78e113fef938f5beb8728f0cc8799c7c1b9f81c1ed9b21
BLAKE2b-256 checksum
How to use checksums
febb0063869a9af4c73fa26816baa6616f1d9a77a7170488dece5c95d2941789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / iq_sdk-0.4.0-py3-none-any.whl

Download URL iq_sdk-0.4.0-py3-none-any.whl
Size 142.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
164c83c12665680c5f342ae3db2a0fb1a3c2e3e2d454f21b58ef2828257dda8a
BLAKE2b-256 checksum
How to use checksums
9808f78fbe0fca578d65ac0899d7309038d1fef73d949307603af53bc663008f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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