Skip to main content

octoprint-cli

No longer maintained. This package receives no further updates. Use kiln3d, which is compatible with OctoPrint and every other printer Kiln supports. Installed copies keep working.

Agent-friendly command-line interface compatible with OctoPrint for 3D printer management.

Designed for autonomous AI agent interaction with structured JSON outputs, clear exit codes, and safety guards for unattended operation.

Installation

pip install .

Or in development mode:

pip install -e ".[dev]"

Quick Start

1. Initialize configuration

octoprint-cli init
# Prompts for host URL and API key, saves to ~/.octoprint-cli/config.yaml

2. Or use environment variables

export OCTOPRINT_HOST="http://octopi.local"
export OCTOPRINT_API_KEY="your_api_key_here"

3. Check printer status

octoprint-cli status --json

Commands

Command Description
status Get printer state, temperatures, and job progress
files List available G-code files on the printer
upload <file> Upload a G-code file
print <file> Upload and start printing (requires --confirm)
cancel Cancel current print (requires --confirm)
pause Pause current print
resume Resume paused print
preflight [file] Run pre-flight safety checks
temp Get or set temperatures
gcode <cmds> Send raw G-code commands
connect Connect printer to OctoPrint
disconnect Disconnect printer from OctoPrint
init Create configuration file

Agent-Friendly Design

Structured JSON Output

Every command supports --json for machine-parseable output:

octoprint-cli status --json
{
  "status": "success",
  "data": {
    "state": "Operational",
    "temperature": {
      "tool0": {"actual": 22.5, "target": 0.0},
      "bed": {"actual": 21.8, "target": 0.0}
    },
    "job": {
      "file": null,
      "completion": null,
      "print_time_left": null
    }
  }
}

Exit Codes

Code Meaning
0 Success
1 Printer offline / unreachable
2 File error (not found, invalid format)
3 Printer busy (already printing)
4 Other error (auth, server, validation)

Safety Flags

Destructive operations require explicit confirmation:

# Will fail without --confirm
octoprint-cli print model.gcode --confirm --json

# Cancel with confirmation
octoprint-cli cancel --confirm --json

Idempotent Operations

# Exits 0 if already printing instead of erroring
octoprint-cli print model.gcode --confirm --skip-if-printing --json

Configuration

Configuration is resolved with this precedence (highest first):

  1. CLI flags (--host, --api-key)
  2. Environment variables (OCTOPRINT_HOST, OCTOPRINT_API_KEY)
  3. Config file (~/.octoprint-cli/config.yaml)

Config File Format

host: "http://octopi.local"
api_key: "YOUR_API_KEY_HERE"
timeout: 30
retries: 3

Agent Workflow Example

A typical autonomous print workflow:

# Step 1: Verify printer is ready
octoprint-cli preflight ./model.gcode --json
# Parse JSON, check "ready": true

# Step 2: Upload and print
octoprint-cli print ./model.gcode --confirm --json
# Parse JSON, check "status": "success"

# Step 3: Monitor progress (poll periodically)
octoprint-cli status --json
# Parse JSON, read data.job.completion and data.job.print_time_left

# Step 4: Handle completion or errors based on exit codes
# Exit 0 = success, 1 = offline, 2 = file error, 3 = busy, 4 = other

Error Handling Example

octoprint-cli status --json
echo "Exit code: $?"
{
  "status": "error",
  "data": null,
  "error": {
    "code": "CONNECTION_ERROR",
    "message": "Could not connect to OctoPrint at http://octopi.local"
  }
}

Exit code: 1 (printer offline)

Pre-flight Checks

The preflight command (and automatic checks before print) validates:

  • Printer is connected and operational
  • Printer is not already printing
  • No printer errors detected
  • Temperatures are within safe limits
  • File exists, has valid extension, reasonable size
octoprint-cli preflight ./model.gcode --json

Temperature Control

# View current temperatures
octoprint-cli temp --json

# Set hotend to 200C and bed to 60C
octoprint-cli temp --tool 200 --bed 60 --json

# Turn off all heaters
octoprint-cli temp --off --json

Raw G-code

# Home all axes
octoprint-cli gcode G28 --json

# Multiple commands
octoprint-cli gcode G28 "M104 S200" "M140 S60" --json

Requirements

  • Python 3.8+
  • OctoPrint server with API access enabled
  • Dependencies: click, requests, pyyaml, rich

License

MIT

Trademarks

OctoPrint is a registered trademark. This package is not affiliated with or endorsed by OctoPrint or Gina Häußge.

Metadata

Release files for kiln3d-octoprint 0.2.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 kiln3d-octoprint 0.2.2
File Size Uploaded Provenance Actions
kiln3d_octoprint-0.2.2.tar.gz 32.5 kB With provenance Details for kiln3d_octoprint-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kiln3d-octoprint 0.2.2
File Interpreter ABI Platform Actions
kiln3d_octoprint-0.2.2-py3-none-any.whl Python 3 none any Details for kiln3d_octoprint-0.2.2-py3-none-any.whl

Total release size: 56.2 kB

Release files / kiln3d_octoprint-0.2.2.tar.gz

Download URL kiln3d_octoprint-0.2.2.tar.gz
Size 32.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6b3ec1c09ab54b190ee4e967733c648b1f63af6ec7842809e3629ca0d5adfb60
BLAKE2b-256 checksum
How to use checksums
ff5c40f0ea218c7d60ad8b4291f4c8bfded3fd5df09324734ad0698632c779a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / kiln3d_octoprint-0.2.2-py3-none-any.whl

Download URL kiln3d_octoprint-0.2.2-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7580ae4f5f07495ef22c2fffdedd50de3c5f4ed59b6063864ed32a6c2c2a5c32
BLAKE2b-256 checksum
How to use checksums
45814ae88b4ac32cb724890a622a0394a2582a358de77db6cd19dff9ab71301d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for kiln3d-octoprint 0.2.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kiln3d_octoprint-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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