How to Build Practical AI Apps with LLM APIs: From Subtitle Translation to Agent Workflows

    This article explains why building your own tools on LLM APIs is worthwhile, then walks through two patterns: an automated video subtitle translation and dubbing pipeline, and an LLM workflow that generates vocabulary memory cards. It covers batching, timestamps, structured JSON output, retries, model choice, privacy, and a path from scripts to workflows to a simple web app.

    Why build your own AI tools

    LLM APIs have lowered the bar for individual developers to ship useful tools. Training models, standing up inference, and handling concurrency used to dominate the work. Now a standard chat API, combined with speech recognition, image generation, and similar capabilities, is often enough to cover a real need.

    Compared with off-the-shelf products, a custom tool has three clear advantages:

    1. Customization: You control prompts, flow, and output format so they match your workflow.
    2. Composition: You can chain recognition, translation, generation, and other steps into an end-to-end pipeline.
    3. Cheap experiments: Usage-based billing means small trials have little sunk cost.

    Two common cases follow: automatic video subtitle translation and dubbing, and Agent-style apps built on workflow orchestration.

    Practice 1: Automatic subtitle translation and dubbing

    End-to-end pipeline

    A flow that takes a video and produces a version with Chinese subtitles (and optionally Chinese audio) usually breaks into five steps:

    1. Extract audio: Separate the soundtrack and convert or split it with a common multimedia library.
    2. Speech recognition: Call an ASR service or a local model to get timestamped transcripts.
    3. Translate subtitles: Send batches of transcript text to an LLM, asking it to translate with context while keeping line length and timing readable.
    4. Burn in subtitles: Build a subtitle file from timestamps and mux it back into the video.
    5. Optional dubbing: Call a TTS API on the translated lines, then replace or mix with the original track.

    Engineering details

    • Batching and context: Do not translate a long video in one call. Batch by sentence or paragraph and put a short summary of prior context in the prompt so terms and person references stay consistent.
    • Timing: Translated Chinese is often shorter or longer than the source. Cap characters per cue so lines do not overflow the frame.
    • Dubbing alignment: TTS duration rarely matches the original timestamps. Generate per sentence, then time-stretch or nudge cues.
    • Quality fallback: Run a light LLM pass on ASR output to fix typos and punctuation; subtitle quality improves noticeably.

    Simplified pseudocode

    1. # Pseudocode: core subtitle translation step
    2. segments = asr_transcribe("audio.wav") # timestamped sentences
    3. for seg in batched(segments, size=20):
    4. prompt = f"""
    5. You are a subtitle translator. Translate the following English lines into Chinese.
    6. Each line must be at most {MAX_LEN} characters, stay conversational, and be numbered.
    7. """
    8. seg.translation = llm.chat(prompt + format(seg))
    9. burn_subtitles("video.mp4", to_srt(segments))

    Once the pipeline works, an hour of English video often gets translated subtitles in a few minutes.

    Practice 2: Agent apps via workflow orchestration

    What LLM workflow orchestration is

    A single Q&A turn rarely finishes a complex job. Workflow platforms treat “detect intent → call tools → generate content → render” as nodes in a directed graph, wired by drag-and-drop or config. Nodes can be LLM calls, code, HTTP requests, or templates. Logic stays visible and easier to debug.

    Example: vocabulary memory cards

    User enters an English word; the system returns a card with definitions, examples, root analysis, and an image. A possible graph:

    1. Input: Receive the word and validate it.
    2. LLM: Structured prompt for definition, IPA, examples, and memory tips, forced JSON for downstream parsing.
    3. Image generation: Use the word’s core image as a prompt.
    4. Render: HTML/CSS template, then screenshot the card.

    Illustrative LLM-node prompt:

    1. Generate memory-card data for the word "{word}". Output JSON only:
    2. {
    3. "phonetic": "IPA",
    4. "definitions": ["up to 3 core senses"],
    5. "examples": ["two natural example sentences"],
    6. "roots": "root and affix breakdown",
    7. "mnemonics": "one-sentence memory tip",
    8. "image_prompt": "English description suitable for image generation"
    9. }

    Design principles

    • Prefer structured output (JSON, not free text) so later nodes parse reliably.
    • Retries and fallbacks on generation nodes (e.g. a placeholder if image generation fails).
    • One concern per node so you can test and swap pieces.
    • Treat prompts as versioned config so you can roll back.

    Stack and shipping notes

    1. Capabilities: Use cloud LLM APIs that cover chat, speech recognition, speech synthesis, and image generation, plus object storage for media and serverless functions for processing. Do not assume any one vendor is available in every region.
    2. Cost: Smaller models for translation and summarization; flagship models only for heavier reasoning.
    3. Privacy: For sensitive audio/video, run recognition locally and send only necessary text to the cloud.
    4. Evolve gradually: Prove the flow in scripts, freeze it on a workflow platform, then wrap a web app or mini-program if needed.

    Closing

    Subtitle translation and Agent workflows are two entry points. Once you own the recognize–understand–generate–render path, the same pattern applies to meeting notes, podcast summaries, study notes, and more. Start with a minimal prototype and iterate on prompts and graph structure—that is a high-leverage practice for individual developers in the LLM era.