Skip to main content

Python client SDK for Middleman.ai API

Project description

Middleman.ai Python SDK

Middleman.ai の API を簡単に利用するための Python SDK です。マークダウン →PDF 変換、JSON→PPTX 変換、PDF ページ → 画像変換などの機能を提供します。

インストール

pip install middleman-ai

基本的な使い方

from middleman_ai import ToolsClient

# クライアントの初期化
client = ToolsClient(api_key="YOUR_API_KEY")

# Markdown → PDF変換
markdown_text = "# Sample\nThis is a test."
pdf_url = client.md_to_pdf(markdown_text)
print(f"Generated PDF URL: {pdf_url}")

CLIの使用方法

SDKはコマンドラインインターフェース(CLI)も提供しています。UVを使用して以下のように実行できます:

# APIキーの設定
export MIDDLEMAN_API_KEY=your-api-key

# Markdown → PDF変換
echo "# テスト" | uvx middleman md-to-pdf

# Markdown → DOCX変換
echo "# テスト" | uvx middleman md-to-docx

# Markdown → PPTX変換
echo "# テスト" | uvx middleman md-to-pptx

# PDF → ページ画像変換
uvx middleman pdf-to-page-images input.pdf

# PPTXテンプレート解析
uvx middleman json-to-pptx-analyze [テンプレートID]

# PPTXテンプレート実行
echo '{"slides":[{"type":"title","placeholders":[{"name":"title","content":"テストタイトル"}]}]}' | \
uvx middleman json-to-pptx-execute [テンプレートID]

各コマンドは標準入力からテキストを受け取るか、必要に応じてファイルパスやテンプレートIDを引数として受け取ります。

機能一覧

  • Markdown → PDF 変換
  • Markdown → DOCX 変換
  • Markdown → PPTX 変換
  • PDF → ページ画像変換
  • JSON → PPTX 変換(テンプレート解析・実行)

エラーハンドリング

from middleman_ai import ToolsClient, NotEnoughCreditError

client = ToolsClient(api_key="YOUR_API_KEY")

try:
    pdf_url = client.md_to_pdf("# Test")
except NotEnoughCreditError:
    print("クレジット不足です。プランをアップグレードしてください。")
except Exception as e:
    print(f"エラーが発生しました: {e}")

ライセンス

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

middleman_ai-0.0.4.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

middleman_ai-0.0.4-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file middleman_ai-0.0.4.tar.gz.

File metadata

  • Download URL: middleman_ai-0.0.4.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for middleman_ai-0.0.4.tar.gz
Algorithm Hash digest
SHA256 fde84f558335e48494d076ddfcd7b3e91431b72e2f5451676d8b60168b08f87f
MD5 25328b01fc455743cd1fc71500e698fd
BLAKE2b-256 016d5364ace61e85a68d6a59aeff2dd4ecb242de25db128516877fd33f3b92ad

See more details on using hashes here.

File details

Details for the file middleman_ai-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: middleman_ai-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for middleman_ai-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8b84f11d2369c6968187a42a8615c3e70a544d1c45cf82ca48aff2c2fd9a3a2b
MD5 b8045a4900a945eaecfe25b3de96b1a8
BLAKE2b-256 6404217fbec0fff4472732293f086f1372edb6a06964d2cd21a6b1a54fe7bfa2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page