DeckFlow Logo Developers DeckFlow documentation
Developer GuideAPI ReferenceMCPCLI

Examples

An introduction to DeckFlow examples, showcasing typical integration scenarios using the API, MCP, and CLI.

This page gathers runnable and copyable code examples, helping you quickly get started with DeckFlow developer tools. All examples are based on the base URL https://app.deckflow.com/api and require the Authorization: Bearer <YOUR_API_KEY> header.

1. API Integration Examples

Submit and poll asynchronous tasks via the HTTP API. The following snippets demonstrate creating a document generation task and polling its status until a download URL is returned.

const API_KEY = "Bearer <YOUR_API_KEY>";
const BASE_URL = "https://app.deckflow.com/api";

async function generateDeck() {
  const formData = new FormData();
  formData.append("type", "generation");
  formData.append("params", JSON.stringify({
    inputText: "Generate a market research report on renewable energy trends",
    pageCount: 10
  }));

  // 1. Submit the task
  const res = await fetch(`${BASE_URL}/tools/tasks`, {
    method: "POST",
    headers: {
      "Authorization": API_KEY
    },
    body: formData
  });
  const task = await res.json();
  console.log("Task submitted. ID:", task.id);

  // 2. Poll the status
  const pollInterval = setInterval(async () => {
    const statusRes = await fetch(`${BASE_URL}/tools/tasks/${task.id}`, {
      headers: {
        "Authorization": API_KEY
      }
    });
    const currentTask = await statusRes.json();
    console.log("Task status:", currentTask.status);

    if (currentTask.status === "completed") {
      clearInterval(pollInterval);
      console.log("Success! Download URL:", currentTask.result.url);
    } else if (currentTask.status === "failed") {
      clearInterval(pollInterval);
      console.error("Task failed. Error:", currentTask.error.message);
    }
  }, 5000);
}

generateDeck();
import time
import requests

API_KEY = "Bearer <YOUR_API_KEY>"
BASE_URL = "https://app.deckflow.com/api"

def generate_deck():
    headers = {
        "Authorization": API_KEY
    }
    data = {
        "type": "generation",
        "params": '{"inputText": "Generate a market research report on renewable energy trends", "pageCount": 10}'
    }

    # 1. Submit the task
    response = requests.post(f"{BASE_URL}/tools/tasks", headers=headers, data=data)
    task = response.json()
    task_id = task["id"]
    print(f"Task submitted. ID: {task_id}")

    # 2. Poll the status
    while True:
        status_response = requests.get(f"{BASE_URL}/tools/tasks/{task_id}", headers=headers)
        current_task = status_response.json()
        status = current_task["status"]
        print(f"Task status: {status}")

        if status == "completed":
            print(f"Success! Download URL: {current_task['result']['url']}")
            break
        elif status == "failed":
            print(f"Task failed. Error: {current_task['error']['message']}")
            break

        time.sleep(5)

generate_deck()

2. CLI (DeckOps) Automation Examples

DeckOps is the command-line utility for managing DeckFlow cloud tasks. You can run batch automation from your local terminal or CI/CD pipelines.

Installation & Configuration

# Clone and link the CLI globally
git clone https://github.com/deckflow/deckops.git
cd deckops
npm install
npm link

# Set credentials
deckops config set-token "Bearer <YOUR_API_KEY>"
deckops config set-api-base "https://app.deckflow.com/api"

Common Commands

# Submit a slide generation task
deckops create --params '{"inputText":"AI development in healthcare","pageCount":8}'

# Translate a deck and wait for the results
deckops translate source_presentation.pptx --from zh --to en --timeout 180

# Compress an archive using the cloud Optimizer
deckops compress large_archive.zip

3. MCP Agent Integration Examples

Configure the DeckFlow MCP server in your AI assistant (e.g. Claude Desktop) to allow LLMs to directly call file optimization, extraction, and generation tools.

Configuration File

Add the following configuration block into your Claude Desktop settings file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "deckflow": {
      "command": "node",
      "args": ["/Users/tong/Downloads/Dev-Docs/heygen-docs/mcp-server/dist/index.js"],
      "env": {
        "DECKFLOW_API_KEY": "Bearer <YOUR_API_KEY>"
      }
    }
  }
}

After saving, restart Claude Desktop to enable the tools inside your chat sessions.