transcribe rejects public YouTube URLs even though the Gemini API supports them
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with internal/cli/custom/media.go for input policy and URL classification, then internal/cli/custom/transcribe.go for model routing, prompts, and artifact rendering. Review the existing transcription behavior and related issue #144 before tracing how video inputs and output formats are handled. Done means public YouTube URLs work across the requested formats, existing audio behavior remains intact, and the listed regression cases and help documentation are covered.
Written by the indexing model from the issue text.
Description
Problem
I expected gemini-api transcribe to accept a public YouTube URL and transcribe the video's spoken audio directly. Instead, the CLI rejects the URL before making an API request and recommends downloading or uploading the media.
This is a CLI restriction, not a missing Gemini API capability. analyze -i <YouTube URL> and agent run -i <YouTube URL> already support passing the URL as a video input. The command users would naturally look for, transcribe, does not.
The CLI should make supported Gemini Developer API capabilities easy to discover and use. Direct YouTube transcription should be a first-class workflow.
Reproduction
Tested with installed gemini-api 0.4.2 and source at 3a9106d94e0522d0b5d9003b5b1c3d262e7d4692 on macOS.
gemini-api transcribe \
-i 'https://www.youtube.com/watch?v=rRJ7Jhun12I' \
--dry-run
The CLI exits with code 2:
YouTube URLs are not supported by transcribe
Download the media locally or upload it with "gemini-api files upload <path>"
Expected: accept the URL as a video input, generate a complete transcript, and support the existing Markdown, text, JSON, and SRT output formats without requiring a local download or Files API upload.
Official API support
The Gemini API video-understanding guide documents direct public YouTube inputs. With the currently supported v1beta content-array shape, the relevant input is:
{
"type": "video",
"uri": "https://www.youtube.com/watch?v=rRJ7Jhun12I"
}
This uses the Gemini Developer API at generativelanguage.googleapis.com, not Vertex AI. The guide documents public-video support and describes the feature as preview.
Live validation
I tested NASA's approximately five-minute Webb Spies Rain Clouds, New Molecule on Titan, using NASA's published reference captions for comparison. The video and reference are linked from NASA's source page.
gemini-3.8-flashtranscribed the URL directly, including the final spoken sentence, without downloading or uploading the video.- One schema-constrained JSON run returned 39 segments and 725 normalized spoken-word tokens versus 723 in the reference.
- Word error rate was 1.24%: 9 word-level insertions, deletions, or substitutions divided by 723 reference words, after lowercasing, splitting into alphanumeric tokens, and excluding caption sound-effect labels.
- All 78 aligned segment start/end boundaries fell within, or at most 1.367 seconds outside, the NASA caption cue containing the corresponding boundary word. This is a comparison with caption intervals, not a claim of word-level timing precision.
- A local prototype produced timestamped Markdown and valid SRT directly from the URL.
There is also a formatting trap: repeated free-form requests returned the transcript but omitted timestamps even though the prompt explicitly requested them. Merely allowing the URL and adding a transcription prompt is not sufficient to honor the command's default timestamp behavior.
Recommended implementation
- Remove the YouTube-specific rejection from transcription input validation. Reuse the existing URL classification and URI-backed video content handling used by
analyze. Do not add a downloader or require an upload. - Route by content type, not only MIME type. Keep
gemini-3.5-transcribefor audio. Route YouTube/video inputs to the video-capable default, currentlygemini-3.8-flash, unless a compatible model is explicitly selected. A YouTube video block has no required MIME type, so the current MIME-only fallback will miss it. Inspect the video content block itself; do not invent a MIME type to trigger routing. - Handle explicit audio-only models clearly. If a user explicitly selects
gemini-3.5-transcribefor a YouTube URL, explain that it accepts audio only and suggest omitting--modelor choosing a video-capable model. - Request structured transcript segments for every YouTube output format. Require
content, plusspeakerandstart_time/end_timewhen requested. Render Markdown, text, JSON, and SRT locally from those segments. This prevents a successful-looking Markdown file from silently dropping timestamps. Preserve--no-speakersand--no-timestampsbehavior; SRT still requires timing. - Ask for complete, verbatim speech. Explicitly prohibit summaries, paraphrases, omitted sections, and added visual descriptions; mark unclear words rather than inventing them. Preserve existing non-success/incomplete response handling.
- Make the capability visible. Mention public YouTube URLs in the root command description,
transcribe --help,--inputdescription, machine-readable usage, and README. Add runnable Markdown and SRT examples. Explain automatic model selection and that video speaker labels/timestamps are model-generated estimates. - Preserve the existing output contract. Continue writing artifacts, printing their paths by default, reporting the effective model per input in machine output, and sending
store: false.
Relevant implementation:
- Input policy, URL classification, and source resolution
- Transcription routing, prompting, and artifact rendering
Related: #144 covers the dedicated audio transcription model. Its audio behavior should be preserved while adding direct YouTube support.
Regression coverage
- Watch URLs, short
youtu.beURLs, and supported mobile/Shorts forms are sent as video URIs. - Default model selection works even when the URI has no MIME type; explicit compatible models remain honored.
- Explicit audio-only models fail before an interaction is sent.
- All four artifact formats preserve requested fields; missing requested timestamps fail without writing an incomplete artifact.
--dry-runpreviews the correct request without network calls or file writes.- Existing local-file/uploaded-file transcription and mixed-input behavior keep working.
- Help and README make the direct URL workflow discoverable.
Current workaround
gemini-api analyze \
-i 'https://www.youtube.com/watch?v=rRJ7Jhun12I' \
--api-version v1beta \
'Transcribe all spoken audio verbatim from beginning to end. Do not summarize, paraphrase, omit sections, or add visual descriptions.' \
> episode.txt
This produces text, but free-form output does not reliably honor timestamp requests. The separate version-compatibility regression is tracked in #177; --api-version v1beta is intentional here.
- Dominant language
- Go
- Stars
- 514
- Forks
- 84
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 69
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google-gemini/gemini-api-cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
google-gemini/gemini-api-cli#231 · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
google-gemini/gemini-api-cli#227 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-api-cli#221 ·
Maintainers usually reply within 1 day
-
..Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
google-gemini/gemini-api-cli#205 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 25/100
google-gemini/gemini-api-cli#188 ·
Maintainers usually reply within 1 day
All issues in google-gemini/gemini-api-cli
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
google/osv-scanner#3327 ·
Maintainers usually reply within 1 day
-
tld-snapshot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
awslabs/ferret-scan#1064 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
VictoriaMetrics/VictoriaTraces#335 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 62/100
DaoCloud/DaoCloud-docs#7839 ·
Maintainers usually reply within 1 day