CLI Quick Start

The Autoken CLI lets you execute tasks directly from your terminal. Perfect for scripting, automation, and quick testing.

Installation

The CLI is included with the Python package:

pip install autoken

Set your API key as an environment variable:

export AUTOKEN_API_KEY="sk_your_api_key_here"

Basic Usage

Execute a Task

Use named arguments to pass inputs:

$ autoken translate-text --text "Hello world" --language "es"
Hola mundo

Positional Arguments

The first argument can be passed positionally:

$ autoken translate-text "Hello world" --language "fr"
Bonjour le monde

List Available Tasks

$ autoken tasks
translate-text: Translate text between languages
transcribe-audio: Transcribe audio to text
text-to-speech: Convert text to audio
generate-image: Generate images from prompts
...

Working with Files (Artifacts)

File Input

Use the --@arg prefix to upload a file:

$ autoken transcribe-audio --@audio ./interview.mp3
Hello and welcome to our podcast...

File Output

Use the --arg@ suffix to save output to a file:

$ autoken text-to-speech --text "Hello world" --audio@ ./greeting.mp3
Audio saved to ./greeting.mp3

Combined Example

Transcribe audio and save the translation:

# Transcribe audio
$ autoken transcribe-audio --@audio ./spanish.mp3 > transcript.txt

# Translate the transcript
$ cat transcript.txt | autoken translate-text --language "en"
Hello, how are you today?

Cost Estimation

Preview Cost Before Execution

Use --dry-run to see the estimated cost:

$ autoken translate-text --text "Hello world" --language "es" --dry-run
Task: translate-text
Estimated cost: $0.001
Provider: autoken-translate

Check Balance

$ autoken balance
Balance: 4.52 USD

JSON Output

Use --json for machine-readable output:

$ autoken translate-text --text "Hello" --language "es" --json
{
  "executionId": "exec_abc123",
  "output": {
    "translatedText": "Hola"
  },
  "tokenCost": 1
}

Scripting Examples

Batch Processing

#!/bin/bash
# Translate multiple files
for file in translations/*.txt; do
  output="translated/$(basename "$file")"
  cat "$file" | autoken translate-text --language "es" > "$output"
  echo "Translated: $file -> $output"
done

Pipeline with jq

# Extract specific fields from JSON output
$ autoken search-web --query "AI news" --json | jq '.output.results[0].title'
"Latest Developments in Artificial Intelligence"