Cap icon indicating copy to clipboard operation
Cap copied to clipboard

Support custom base URLs for self-hosted AI providers (vLLM, self-hosted Whisper, etc.)

Open jask87 opened this issue 4 months ago • 6 comments

Cap's self-hosting docs currently support AI features only via fixed cloud providers — DEEPGRAM_API_KEY for transcription, and OPENAI_API_KEY / GROQ_API_KEY / ANTHROPIC_API_KEY for summaries. For teams self-hosting Cap specifically for data sovereignty, having AI calls still go out to third-party clouds undercuts the point. Request: Add optional base-URL overrides so these features can point at self-hosted infrastructure instead:

OPENAI_BASE_URL (or similar) so the summary/title/chapter generation can point at an OpenAI-compatible endpoint — e.g. vLLM, which exposes a drop-in-compatible /v1/chat/completions API. This should be a small change since the OpenAI SDK already supports a baseURL param. A similar override for transcription — either a DEEPGRAM_BASE_URL (Deepgram supports self-hosted deployments too), or more flexibly, support for any OpenAI-compatible /v1/audio/transcriptions endpoint, which self-hosted Whisper servers (including vLLM's own transcription API) already expose.

This would let self-hosters keep all AI processing entirely on their own infrastructure, matching the same self-hosting story that already applies to storage (S3-compatible) and the media server.

jask87 avatar Jul 10 '26 16:07 jask87

CAP-755

linear[bot] avatar Jul 10 '26 16:07 linear[bot]

You're right that this should be a relatively small change for the OpenAI-compatible endpoints. Here's what I found in the codebase:

For AI summaries/title/chapter generation:

The OpenAI calls are made via raw fetch() in apps/web/workflows/generate-ai.ts (see callOpenAi function around line 432-449). It currently hardcodes https://api.openai.com/v1/chat/completions. The Groq client in apps/web/lib/groq-client.ts uses the groq-sdk which also supports a baseURL constructor option.

There's also apps/web/lib/messenger/agent.ts which makes direct OpenAI calls for the chat feature (line 592-620).

To implement OPENAI_BASE_URL, you'd need to:

  1. Add the env var to packages/env/server.ts (where all other AI keys are defined, around line 89-92)
  2. Update callOpenAi() in generate-ai.ts to use it
  3. Update the messenger agent's OpenAI call similarly

For transcription:

This is more involved. Transcription uses the Deepgram SDK (@deepgram/sdk) in apps/web/workflows/transcribe.ts (line 342-355). The SDK's createClient() doesn't expose a simple baseURL override like OpenAI's does.

Two paths forward:

  • DEEPGRAM_BASE_URL: Would need changes to the Deepgram client initialization. Deepgram's self-hosted deployments use the same API format.
  • OpenAI-compatible transcription endpoint: Would require a more significant refactor to support an alternative transcription provider alongside Deepgram. The transcription flow extracts audio to MP3 first (extractAudio step), then sends it to Deepgram.

For reference, the transcription options are configured in getDeepgramTranscriptionOptions() (line 304-325) and use the nova-3 model with smart formatting and utterance detection.

tembo[bot] avatar Jul 10 '26 16:07 tembo[bot]

How does this sound @richiemcilroy ?

Summaries/titles/chapters — Cap can now talk to three kinds of LLM backends, in this order of preference:

  1. Your own OpenAI-compatible server (e.g. vLLM) — if you set LLM_BASE_URL
  2. Your own Anthropic-style server — if you set ANTHROPIC_BASE_URL
  3. Cloud Groq, then cloud OpenAI — the existing behavior, unchanged (Only if you're not self hosted)

There's one new toggle: LLM_PROVIDER="anthropic" makes the Anthropic-style server the one used; the OpenAI-compatible path is then ignored. The key rule for self-hosted users: if you point Cap at your own server, it will not silently fall back to the cloud if your server fails. If your vLLM errors, you get an error . same for Messenger (the in-app support chat).

Docs "Ask AI" — it currently only speaks Anthropic. If you set LLM_BASE_URL, it will now also talk to an OpenAI-compatible server.

Transcription:

Transcription always used to go to AssemblyAI's cloud. Now, if you set TRANSCRIPTION_BASE_URL, it goes to your own OpenAI-compatible Whisper server instead (e.g. vLLM or a self-hosted Whisper server). AssemblyAI stays the default when you haven't configured your own. Before uploading any audio, Cap checks the server (openapi.json) to see if Word timestamps are supported, so if :

  • Server says yes → proceed normally
  • Server says no → we stop before uploading anything, with a clear message
  • Server doesn't expose that info at all → we stop too, unless you set TRANSCRIPTION_SKIP_CAPABILITY_CHECK=true

The "required" pairing rules. LLM_BASE_URL ⇒ LLM_MODEL + LLM_API_KEY required; ANTHROPIC_BASE_URL ⇒ ANTHROPIC_API_KEY required; TRANSCRIPTION_BASE_URL ⇒ TRANSCRIPTION_MODEL + TRANSCRIPTION_API_KEY required. All base URLs include /v1.

These are all of the new Env vars required: LLM_BASE_URL LLM_MODEL LLM_API_KEY LLM_PROVIDER ANTHROPIC_BASE_URL ANTHROPIC_MODEL TRANSCRIPTION_BASE_URL TRANSCRIPTION_MODEL TRANSCRIPTION_API_KEY TRANSCRIPTION_SKIP_CAPABILITY_CHECK

kkchemboli avatar Aug 03 '26 18:08 kkchemboli

A provider-neutral contract would avoid downstream patches for self-hosted ASR engines, including non-Whisper ONNX backends.

A low-overhead MVP could use an OpenAI-compatible adapter configured with server-side environment variables:

TRANSCRIPTION_PROVIDER=openai-compatible
TRANSCRIPTION_BASE_URL=https://asr.example.com/v1
TRANSCRIPTION_MODEL=custom-asr-model
TRANSCRIPTION_API_KEY=...
TRANSCRIPTION_TIMEOUT_SECONDS=3600

Cap would call:

POST {TRANSCRIPTION_BASE_URL}/audio/transcriptions
Authorization: Bearer ...
Content-Type: multipart/form-data

file=<audio>
model=<TRANSCRIPTION_MODEL>
response_format=verbose_json
timestamp_granularities[]=word

and accept the standard verbose response shape:

{
  "text": "...",
  "words": [{ "word": "...", "start": 0.0, "end": 0.4 }],
  "segments": []
}

A few implementation details seem important:

  • Please do not require /openapi.json as a capability check. Many ASR services do not expose it, and a schema cannot reliably guarantee that a particular model returns word timestamps. Requesting verbose_json and validating words in the response is more interoperable. A strict preflight can remain opt-in.
  • Keep the API key and provider URL server-side.
  • Allow HTTP endpoints for private/self-hosted networks.
  • Never silently fall back to a cloud provider when a custom endpoint is configured.
  • Preserve word-level timestamps for captions, editing, and VTT output; a documented segments-only fallback would also help.
  • Make the timeout configurable because long recordings can exceed ordinary reverse-proxy timeouts.

For larger recordings, a synchronous OpenAI-compatible request may still be limiting. A later optional async protocol could be selected with something like TRANSCRIPTION_PROTOCOL=async: POST /transcriptions -> 202 {id}, poll GET /transcriptions/{id}, then DELETE for cleanup. Supporting the OpenAI-compatible endpoint first would already cover Whisper, vLLM, custom ASR gateways, and other local engines.

Happy to help validate the contract against a non-Whisper ONNX backend and contribute a small PR once the preferred interface is confirmed.

moskvini avatar Aug 11 '26 13:08 moskvini

Thanks! Since #2113 you can point titles, summaries and chapters at any OpenAI-compatible server with AI_PROVIDER=openai-compatible and AI_BASE_URL. Transcription still goes through AssemblyAI, so we'll keep this open for a self-hosted option there.

richiemcilroy avatar Nov 04 '26 16:11 richiemcilroy

Thanks for the update! I also noticed #3523, which looks promising for self-hosted transcription through an OpenAI-compatible endpoint.

For context, we have been running GigaAM v3 with our self-hosted Cap using a downstream integration. Our ASR service currently uses an asynchronous API: submit audio, poll for the result, and clean up the job. It returns word-level timestamps for captions and the transcript editor. This is a different protocol from the endpoint proposed in #3523, so it would need an adapter.

I opened draft #3756 as a concrete proposal for the async approach. It still needs server tests and compiled workflow verification; the draft also describes its worker-restart and job-cleanup limitations.

Would an optional asynchronous provider protocol be useful as a follow-up, particularly for long recordings, or would you prefer self-hosters to provide an OpenAI-compatible adapter? I can help validate the integration with GigaAM.

moskvini avatar Nov 04 '26 17:11 moskvini