---
title: prompt
---

<div class="python-reference">
<a id="fastvideo.entrypoints.streaming.prompt-classes"></a>
<a id="fastvideo.entrypoints.streaming.prompt.PromptEnhancer-functions"></a>
<a id="fastvideo.entrypoints.streaming.prompt"></a>
<p>Prompt pipeline for the streaming server.</p>
<ul>
<li>:mod:<code>providers</code> — LLM backend abstraction + built-in adapters</li>
<li>:mod:<code>enhancer</code> — provider-agnostic enhance / auto-extend / rewrite
  operations on top of the provider layer</li>
</ul>
<p>All of this is optional; the streaming server runs fine without it
(PR 7.5's skeleton never invokes the enhancer). When the operator
enables <code>ServeConfig.streaming.prompt.enabled</code>, the server routes
each <code>session_init_v2</code> curated prompt through <code>enhance</code> before the
first segment.</p>
<h2 id="fastvideo.entrypoints.streaming.prompt.PromptEnhancer"><code>fastvideo.entrypoints.streaming.prompt.PromptEnhancer</code></h2>
<pre class="doc-signature"><code>PromptEnhancer(*, providers: Sequence&#91;LLMProvider&#93;, model: str, timeout_ms: int = 20000, temperature: float = 0.7, max_tokens: int | None = 256, system_prompt_dir: str | None = None)</code></pre>
<p>Orchestrates prompt operations across a priority-ordered provider
list with structured fallback + hot-reloadable system prompts.</p>
<p>Usage::</p>
<pre><code>enhancer = PromptEnhancer(
    providers=[CerebrasProvider(), GroqProvider()],
    model="gpt-oss-120b",
    system_prompt_dir="/etc/fastvideo/prompts",
)
response = await enhancer.enhance("a fox running through snow")
</code></pre>

<h3 id="fastvideo.entrypoints.streaming.prompt.PromptEnhancer.register_provider"><code>fastvideo.entrypoints.streaming.prompt.PromptEnhancer.register_provider</code></h3>
<pre class="doc-signature"><code>register_provider(provider: LLMProvider, *, priority: int = -1) -&gt; None</code></pre>
<p>Insert an additional provider. <code>priority=0</code> makes it primary;
<code>priority=-1</code> (default) appends as a fallback.</p>
<h3 id="fastvideo.entrypoints.streaming.prompt.PromptEnhancer.reload_system_prompts"><code>fastvideo.entrypoints.streaming.prompt.PromptEnhancer.reload_system_prompts</code></h3>
<pre class="doc-signature"><code>reload_system_prompts() -&gt; None</code></pre>
<p>Re-read the system prompt files from <code>system_prompt_dir</code>.</p>
<p>The streaming server exposes this via a management endpoint so
operators can iterate on prompt templates without restarting
workers.</p>
<h3 id="fastvideo.entrypoints.streaming.prompt.PromptEnhancer.enhance"><code>fastvideo.entrypoints.streaming.prompt.PromptEnhancer.enhance</code></h3>
<pre class="doc-signature"><code>enhance(prompt: str) -&gt; LLMResponse</code></pre>

<h3 id="fastvideo.entrypoints.streaming.prompt.PromptEnhancer.auto_extend"><code>fastvideo.entrypoints.streaming.prompt.PromptEnhancer.auto_extend</code></h3>
<pre class="doc-signature"><code>auto_extend(prior_prompts: Sequence&#91;str&#93;) -&gt; LLMResponse</code></pre>

<h3 id="fastvideo.entrypoints.streaming.prompt.PromptEnhancer.rewrite"><code>fastvideo.entrypoints.streaming.prompt.PromptEnhancer.rewrite</code></h3>
<pre class="doc-signature"><code>rewrite(seed_prompt: str) -&gt; LLMResponse</code></pre>

<h2 id="fastvideo.entrypoints.streaming.prompt.PromptOperation"><code>fastvideo.entrypoints.streaming.prompt.PromptOperation</code></h2>
<pre class="doc-signature"><code>PromptOperation()</code></pre>

<h2 id="fastvideo.entrypoints.streaming.prompt.LLMMessage"><code>fastvideo.entrypoints.streaming.prompt.LLMMessage</code></h2>
<pre class="doc-signature"><code>LLMMessage(role: Literal&#91;&#x27;system&#x27;, &#x27;user&#x27;, &#x27;assistant&#x27;&#93;, content: str)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.prompt.LLMProvider"><code>fastvideo.entrypoints.streaming.prompt.LLMProvider</code></h2>
<pre class="doc-signature"><code>LLMProvider()</code></pre>
<p>Provider interface every LLM adapter implements.</p>
<p>Providers are async-first because every built-in implementation
talks to an HTTP API. Synchronous providers can wrap their call in
<code>asyncio.to_thread</code> internally.</p>
<h3 id="fastvideo.entrypoints.streaming.prompt.LLMProvider.complete"><code>fastvideo.entrypoints.streaming.prompt.LLMProvider.complete</code></h3>
<pre class="doc-signature"><code>complete(request: LLMRequest) -&gt; LLMResponse</code></pre>

<h2 id="fastvideo.entrypoints.streaming.prompt.LLMProviderError"><code>fastvideo.entrypoints.streaming.prompt.LLMProviderError</code></h2>
<pre class="doc-signature"><code>LLMProviderError(message: str, *, retryable: bool = True)</code></pre>
<p>Raised when an LLM provider fails a request.</p>
<p><code>retryable</code> controls whether the enhancer falls back to the next
provider. It is settable per-instance so the same exception type
can describe retryable transport errors (5xx, 429) and
non-retryable client errors (4xx auth/bad-request) without forcing
a separate subclass for every status family.</p>

<h2 id="fastvideo.entrypoints.streaming.prompt.LLMRequest"><code>fastvideo.entrypoints.streaming.prompt.LLMRequest</code></h2>
<pre class="doc-signature"><code>LLMRequest(messages: list&#91;LLMMessage&#93;, model: str, max_tokens: int | None = None, temperature: float | None = None, timeout_ms: int | None = None)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.prompt.LLMResponse"><code>fastvideo.entrypoints.streaming.prompt.LLMResponse</code></h2>
<pre class="doc-signature"><code>LLMResponse(content: str, provider: str, model: str, latency_ms: float, fallback_used: bool = False)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.prompt.LLMTimeoutError"><code>fastvideo.entrypoints.streaming.prompt.LLMTimeoutError</code></h2>
<pre class="doc-signature"><code>LLMTimeoutError(message: str)</code></pre>
<p>Raised when an LLM provider times out — always retryable.</p>

</div>

<h2>Submodules</h2>
<ul>
<li><a href="/FastVideo/api/fastvideo/entrypoints/streaming/prompt/enhancer">enhancer</a></li>
<li><a href="/FastVideo/api/fastvideo/entrypoints/streaming/prompt/providers">providers</a></li>
<li><a href="/FastVideo/api/fastvideo/entrypoints/streaming/prompt/rewrite">rewrite</a></li>
<li><a href="/FastVideo/api/fastvideo/entrypoints/streaming/prompt/safety">safety</a></li>
</ul>
