Component
Vue AI Input Component
<DomAiInput>Compose a prompt with files and choose a model with its supported workflow modes, reasoning efforts, and speeds.
Playground
AI input playground
Change properties, type a Markdown shortcut in the prompt, or send it to see the request.
Properties
npm install @getdom/studio<script setup>
import '@getdom/studio/style.css';
import { reactive, ref } from 'vue';
import { DomAiInput } from '@getdom/studio';
const data = reactive({
modelValue: {
text: 'Summarise the work left for launch.\n\n- Flag any dependencies.\n\n[] Review the draft\n[x] Confirm the launch date',
mode: 'plan',
},
models: [
{
id: 'example:general',
label: 'General assistant',
provider: 'Example models',
features: {
modes: ['plan', 'build'],
reasoningEfforts: [{ value: 'medium', label: 'Medium' }, { value: 'high', label: 'High' }],
speeds: [{ value: 'standard', label: 'Standard' }, { value: 'fast', label: 'Fast' }],
},
},
],
layout: 'workflow',
modeInPicker: false,
modelPicker: 'stack',
modelPlacement: 'leading',
submitOnEnter: true,
markdown: true,
placeholder: 'Ask AI…',
ariaLabel: 'Playground prompt',
rows: 2,
maxRows: 8,
resolvedModelLabel: '',
disabled: false,
submitting: false,
submitDisabled: false,
});
const lastRequest = ref(null);
defineExpose({ data });
/**
* Displays the most recent request and clears the accepted demo draft.
*
* @param {import('@getdom/studio/vue').AiInputRequest} request Submitted prompt, files, and settings.
* @returns {void}
*/
function recordRequest(request) {
lastRequest.value = {
...request,
attachments: request.attachments.map((file) => file.name),
};
data.modelValue = { ...data.modelValue, text: '', attachments: [] };
}
</script>
<template>
<div class="w-full min-w-0 max-w-2xl space-y-4">
<DomAiInput v-bind="data" v-model="data.modelValue" @submit="recordRequest" />
<section v-if="lastRequest" class="rounded-xl border border-border bg-canvas p-3" role="status">
<p class="text-xs font-semibold text-muted-fg">Last submitted request</p>
<pre class="mt-1.5 max-h-48 overflow-auto text-xs leading-5">{{ JSON.stringify(lastRequest, null, 2) }}</pre>
</section>
</div>
</template>
Sliding stack and workflow layouts
Use the plus button to add local files. Open the model picker to see its features, then send a prompt to inspect the request. The OpenAI, Anthropic, and Google entries are sample catalogue data. Files and prompts stay in this page.
Auto only
A short prompt with file attachments. The app chooses the model.
Compact toolbar
Set the workflow beside the attachment button. Open the model picker for reasoning effort and speed.
Built-in workflow menu
Switch between Plan and Build beside the attachment button.
npm install @getdom/studio<script setup>
import '@getdom/studio/style.css';
import { reactive } from 'vue';
import { DomAiInput, DomDropdown } from '@getdom/studio';
const medium = { value: 'medium', label: 'Medium' };
const low = { value: 'low', label: 'Low' };
const high = { value: 'high', label: 'High' };
const standard = { value: 'standard', label: 'Standard' };
const studioSpeeds = [standard, { value: 'fast', label: 'Fast' }, { value: 'ultrafast', label: 'Ultrafast' }];
const workflowOptions = [{ value: 'plan', label: 'Plan' }, { value: 'build', label: 'Build' }];
const models = [
{
id: 'openai:sol', provider: 'OpenAI', label: 'GPT-6.2 Sol', description: 'General-purpose coding and editing.',
features: { modes: ['plan', 'build'], reasoningEfforts: [medium, low, high], speeds: studioSpeeds },
},
{
id: 'openai:astra', provider: 'OpenAI', label: 'GPT-6.2 Astra', description: 'Longer, more involved tasks.',
features: { modes: ['plan', 'build'], reasoningEfforts: [high, medium, { value: 'xhigh', label: 'Extra high' }], speeds: studioSpeeds },
},
{
id: 'anthropic:sonnet', provider: 'Anthropic', label: 'Claude Sonnet', description: 'Planning, writing, and code review.',
features: { modes: ['plan', 'build'], reasoningEfforts: [medium, high], speeds: [standard] },
},
{
id: 'anthropic:opus', provider: 'Anthropic', label: 'Claude Opus', description: 'Deep analysis of complex tasks.',
features: { modes: ['plan', 'build'], reasoningEfforts: [high, medium], speeds: [standard] },
},
{
id: 'google:flash', provider: 'Google', label: 'Gemini Flash', description: 'Quick tasks and summaries.',
features: { modes: ['plan'], speeds: [standard] },
},
{
id: 'google:pro', provider: 'Google', label: 'Gemini Pro', description: 'Exploring large amounts of context.',
features: { modes: ['plan', 'build'], reasoningEfforts: [low, high], speeds: [standard] },
},
];
const examples = reactive([
{
id: 'auto-only',
title: 'Auto only',
description: 'A short prompt with file attachments. The app chooses the model.',
placeholder: 'What would you like help with?',
rows: 1,
layout: 'toolbar',
models: [],
draft: {},
submission: null,
},
{
id: 'compact-toolbar',
title: 'Compact toolbar',
description: 'Set the workflow beside the attachment button. Open the model picker for reasoning effort and speed.',
placeholder: 'Describe what you want to build…',
rows: 2,
layout: 'toolbar',
models,
draft: { mode: 'build', model: 'auto' },
autoFeatures: { speeds: [standard] },
submission: null,
},
{
id: 'visible-workflow',
title: 'Built-in workflow menu',
description: 'Switch between Plan and Build beside the attachment button.',
placeholder: 'What should we work on?',
rows: 3,
layout: 'workflow',
models,
draft: { mode: 'plan', model: 'openai:sol' },
submission: null,
},
]);
/**
* Applies the workflow chosen in the app's separate toolbar control.
* @param {object} example Reactive demo state.
* @param {'plan' | 'build'} mode Chosen workflow mode.
*/
function setWorkflow(example, mode) {
example.draft = { ...example.draft, mode };
}
/**
* Records a preview of the submitted request and resets the example prompt.
*
* @param {object} example Reactive demo state.
* @param {import('@getdom/studio/vue').AiInputRequest} request Submitted prompt and settings.
* @returns {void}
*/
function previewRequest(example, request) {
const model = example.models.find((option) => option.id === request.model);
example.submission = {
text: request.text,
files: request.attachments.map((file) => file.name),
settings: [
model?.label ?? 'Auto',
request.mode,
model?.features.reasoningEfforts?.find((option) => option.value === request.reasoningEffort)?.label,
request.speed,
].filter(Boolean).join(' · '),
};
example.draft = { ...example.draft, text: '', attachments: [] };
}
</script>
<template>
<div class="w-full max-w-3xl divide-y divide-border">
<section v-for="example in examples" :id="example.id" :key="example.id" class="scroll-mt-24 space-y-4 py-7 first:pt-0 last:pb-0">
<div class="space-y-1">
<h3 class="text-base font-semibold tracking-tight">{{ example.title }}</h3>
<p class="text-sm leading-6 text-muted-fg">{{ example.description }}</p>
</div>
<DomAiInput
v-model="example.draft"
:aria-label="`${example.title} prompt`"
:placeholder="example.placeholder"
:rows="example.rows"
:layout="example.layout"
:mode-in-picker="false"
:models="example.models"
:auto-features="example.autoFeatures"
@submit="previewRequest(example, $event)"
>
<template v-if="example.id === 'compact-toolbar'" #tools="{ disabled }">
<DomDropdown
:items="workflowOptions"
:label="example.draft.mode === 'plan' ? 'Plan' : 'Build'"
:disabled="disabled"
trigger-class="inline-flex min-h-9 items-center gap-1 rounded-lg px-2 text-sm text-muted-fg outline-none hover:bg-secondary focus-visible:ring-2 focus-visible:ring-ring/60"
placement="top"
@select="setWorkflow(example, $event)"
/>
</template>
</DomAiInput>
<div v-if="example.submission" class="space-y-1 rounded-xl border border-border bg-secondary/40 px-4 py-3 text-sm" role="status">
<p class="font-semibold">Request preview</p>
<p v-if="example.submission.text" class="whitespace-pre-wrap wrap-anywhere">{{ example.submission.text }}</p>
<p v-if="example.submission.files.length" class="wrap-anywhere text-muted-fg">{{ example.submission.files.join(', ') }}</p>
<p class="capitalize text-muted-fg">{{ example.submission.settings }}</p>
</div>
</section>
</div>
</template>
Claude-style flyout picker
Choose a model from a compact list. Reasoning effort and additional models open in side menus.
npm install @getdom/studio<script setup>
import '@getdom/studio/style.css';
import { ref } from 'vue';
import { DomAiInput } from '@getdom/studio';
const reasoningEfforts = [
{ value: 'medium', label: 'Medium' },
{ value: 'low', label: 'Low' },
{ value: 'high', label: 'High' },
{ value: 'max', label: 'Maximum' },
];
const models = [
{ id: 'anthropic:opus', label: 'Claude Opus', provider: 'Anthropic', features: { reasoningEfforts } },
{ id: 'anthropic:sonnet', label: 'Claude Sonnet', provider: 'Anthropic', features: { reasoningEfforts: reasoningEfforts.slice(0, 3) } },
{ id: 'anthropic:haiku', label: 'Claude Haiku', provider: 'Anthropic' },
{ id: 'openai:sol', label: 'GPT-6.2 Sol', provider: 'OpenAI', features: { reasoningEfforts: reasoningEfforts.slice(0, 3) } },
];
const draft = ref({ text: 'Compare the trade-offs in these approaches.', model: 'anthropic:opus' });
const request = ref(null);
/**
* Displays the provider choice and reasoning effort from the submitted draft.
* @param {import('@getdom/studio/vue').AiInputRequest} value Submitted demo request.
*/
function send(value) {
request.value = value;
draft.value = { ...draft.value, text: '', attachments: [] };
}
</script>
<template>
<div class="w-full max-w-3xl space-y-3">
<DomAiInput
v-model="draft"
:models="models"
:mode-in-picker="false"
model-picker="flyout"
aria-label="Flyout composer prompt"
placeholder="What would you like to explore?"
@submit="send"
/>
<p v-if="request" role="status" class="wrap-anywhere text-sm text-muted-fg">
Submitted to {{ models.find((model) => model.id === request.model)?.label || 'Auto' }}<span v-if="request.reasoningEffort"> · {{ request.reasoningEffort }} effort</span>
</p>
</div>
</template>
Codex-style coding toolbar
Start the microphone to record with a live waveform. Use Send to submit the recording to the local demo, or use × to discard it.
Microphone off
npm install @getdom/studio<script setup>
import '@getdom/studio/style.css';
import { computed, onBeforeUnmount, ref } from 'vue';
import { DomAiInput, DomAudioControls, DomDropdown } from '@getdom/studio';
const efforts = [{ value: 'medium', label: 'Medium' }, { value: 'high', label: 'High' }, { value: 'low', label: 'Low' }];
const models = [
{ id: 'openai:sol', label: 'GPT-6.2 Sol', provider: 'OpenAI', features: { reasoningEfforts: efforts } },
{ id: 'openai:astra', label: 'GPT-6.2 Astra', provider: 'OpenAI', features: { reasoningEfforts: [{ value: 'high', label: 'High' }, ...efforts.filter((option) => option.value !== 'high')] } },
];
const workflow = [{ value: 'build', label: 'Build' }, { value: 'plan', label: 'Plan' }];
const approvalOptions = [{ value: 'review', label: 'Review changes' }, { value: 'auto', label: 'Auto-approve changes' }];
const settingsButtonClass = 'inline-flex min-h-9 items-center gap-1 rounded-lg px-2 text-sm text-muted-fg outline-none hover:bg-secondary hover:text-canvas-fg focus-visible:ring-2 focus-visible:ring-ring/60';
const draft = ref({ text: '', model: 'openai:sol', reasoningEffort: 'high', mode: 'build' });
const approvals = ref('review');
const request = ref(null);
const microphone = ref(null);
const recording = ref(false);
const submitting = ref(false);
const recordingError = ref('');
const audioUrls = ref([]);
const approvalLabel = computed(() => approvalOptions.find((option) => option.value === approvals.value).label);
let recorder;
let segments = [];
let disposed = false;
/**
* Applies the workflow requested by the application toolbar.
* @param {'plan' | 'build'} mode Selected workflow.
*/
function setWorkflow(mode) {
draft.value = { ...draft.value, mode };
}
/**
* Finalises the current audio segment before its microphone track is released.
*/
function finishSegment() {
if (recorder?.state === 'recording') recorder.stop();
recorder = undefined;
}
/**
* Starts recording the active microphone. Changing devices preserves earlier
* segments. Stopping from the microphone controls discards the unsent audio.
*
* @param {MediaStream | null} stream Current microphone stream.
*/
function onMicrophoneStream(stream) {
finishSegment();
if (!stream) {
recording.value = false;
segments = [];
return;
}
try {
const segment = new MediaRecorder(stream);
let blob;
const result = new Promise((resolve) => {
/** Stores the completed audio emitted before the stop event. */
segment.ondataavailable = (event) => { blob = event.data; };
/** Resolves only after the browser has delivered the audio. */
segment.onstop = () => resolve(blob?.size ? blob : null);
/** Ends a failed capture without enabling an empty submission. */
segment.onerror = () => {
resolve(null);
if (recorder !== segment) return;
recordingError.value = 'Audio recording failed. Start the microphone to try again.';
microphone.value?.stop();
};
});
segment.start();
recorder = segment;
segments.push(result);
recordingError.value = '';
recording.value = true;
} catch {
recordingError.value = 'This browser could not start an audio recording.';
microphone.value?.stop();
}
}
/** Releases audio previews when the next request is accepted or the demo leaves. */
function clearAudioPreviews() {
for (const url of audioUrls.value) URL.revokeObjectURL(url);
audioUrls.value = [];
}
/**
* Sends the composer draft and any recorded audio to the local request preview.
*
* @param {import('@getdom/studio/vue').AiInputRequest} value Submitted composer request.
*/
async function send(value) {
if (submitting.value) return;
const pendingAudio = segments;
const approval = approvals.value;
submitting.value = true;
try {
finishSegment();
microphone.value?.stop();
const audio = (await Promise.all(pendingAudio)).filter(Boolean);
if (disposed) return;
if (pendingAudio.length && !audio.length) {
recordingError.value = 'No audio was captured. Start the microphone and try again.';
return;
}
clearAudioPreviews();
audioUrls.value = audio.map((clip) => URL.createObjectURL(clip));
request.value = {
...value,
approvals: approval,
attachments: value.attachments.map(({ name }) => name),
...(audio.length ? { audio: audio.map(({ type, size }) => ({ type, bytes: size })) } : {}),
};
recordingError.value = '';
draft.value = { ...draft.value, text: '', attachments: [] };
} finally {
submitting.value = false;
}
}
/** Cleans up active recording, microphone tracks, and local playback URLs. */
function dispose() {
disposed = true;
finishSegment();
microphone.value?.stop();
clearAudioPreviews();
}
onBeforeUnmount(dispose);
</script>
<template>
<div class="w-full max-w-3xl space-y-2">
<DomDropdown
:items="workflow"
:label="`Workflow · ${draft.mode === 'plan' ? 'Plan' : 'Build'}`"
:trigger-class="settingsButtonClass"
@select="setWorkflow"
/>
<DomAiInput
v-model="draft"
:models="models"
:mode-in-picker="false"
model-picker="flyout"
model-placement="trailing"
markdown
:allow-empty-submit="recording"
:submitting="submitting"
aria-label="Coding composer prompt"
placeholder="Describe the change you want to make…"
@submit="send"
>
<template #tools="{ disabled }">
<DomDropdown :items="approvalOptions" :label="approvalLabel" :disabled="disabled" :trigger-class="settingsButtonClass" placement="top" @select="approvals = $event" />
</template>
<template #actions="{ disabled }">
<DomAudioControls ref="microphone" compact label="Start microphone" :disabled="disabled" @stream="onMicrophoneStream" />
</template>
</DomAiInput>
<p v-if="recordingError" role="alert" class="text-sm text-destructive">{{ recordingError }}</p>
<div v-if="request" class="space-y-2 rounded-lg border border-border bg-canvas p-3">
<p role="status" class="text-xs font-semibold text-muted-fg">{{ audioUrls.length ? 'Voice prompt sent to the local demo' : 'Submitted request' }}</p>
<audio
v-for="(url, index) in audioUrls"
:key="url"
:src="url"
:aria-label="`Sent audio ${index + 1}`"
class="block w-full max-w-sm"
controls
/>
<pre class="mt-1 max-h-36 overflow-auto text-xs leading-5">{{ JSON.stringify(request, null, 2) }}</pre>
</div>
</div>
</template>
Try a simulated voice prompt
Click the microphone to fill the prompt with a sample transcript. Edit it, then send to watch the sample reply stream in. Playback uses a voice on your device when available.
npm install @getdom/studio<script setup>
import '@getdom/studio/style.css';
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { DomAiInput, DomButton, DomIconButton } from '@getdom/studio';
const transcriptChunks = ['Draft a quick plan ', 'for the next ', 'set of release notes.'];
const replyChunks = [
'Start with a short summary of what changed. ',
'Group the new features and fixes, then call out any upgrade steps. ',
'Finish with a link to the full changelog.',
];
const microphoneIcon = 'M9 5a3 3 0 0 1 6 0v7a3 3 0 0 1-6 0V5ZM5 10v2a7 7 0 0 0 14 0v-2M12 19v3';
const draft = ref({ text: '' });
const phase = ref('idle');
const transcript = ref('');
const submittedPrompt = ref('');
const reply = ref('');
const announcement = ref('');
const playing = ref(false);
const playbackError = ref('');
const micLabel = computed(() => phase.value === 'dictating' ? 'Finish sample dictation' : 'Start sample dictation');
let scheduledChunk;
let utterance;
/**
* Emits each scripted chunk once at the given cadence, then completes the sample.
*
* @param {string[]} chunks Nonempty, ordered sample fragments.
* @param {import('vue').Ref<string>} output Text displayed as the sample arrives.
* @param {number} interval Milliseconds between fragments.
* @param {() => void} finish Callback when the last fragment has arrived.
* @returns {void}
*/
function streamSample(chunks, output, interval, finish) {
let index = 0;
/** Appends one fragment and schedules its successor if one remains. */
function deliver() {
output.value += chunks[index++];
if (index < chunks.length) {
scheduledChunk = setTimeout(deliver, interval);
} else {
scheduledChunk = undefined;
finish();
}
}
scheduledChunk = setTimeout(deliver, interval);
}
/**
* Finalises any received sample text without overwriting edits made during dictation.
*
* @returns {void}
*/
function finishDictation() {
clearTimeout(scheduledChunk);
scheduledChunk = undefined;
if (transcript.value.trim()) {
const text = [draft.value.text.trimEnd(), transcript.value.trim()].filter(Boolean).join('\n\n');
draft.value = { ...draft.value, text };
announcement.value = 'Sample transcript added to the prompt.';
} else {
announcement.value = 'Sample dictation ended.';
}
phase.value = 'idle';
}
/**
* Starts sample dictation, or commits the portion heard when the visitor stops it.
*
* @returns {void}
*/
function toggleDictation() {
if (phase.value === 'dictating') {
finishDictation();
return;
}
if (phase.value === 'responding') return;
transcript.value = '';
phase.value = 'dictating';
announcement.value = 'Simulating dictation.';
streamSample(transcriptChunks, transcript, 500, finishDictation);
}
/**
* Accepts the edited prompt and begins streaming the sample assistant reply.
*
* @param {import('@getdom/studio/vue').AiInputRequest} request Submitted composer value.
* @returns {void}
*/
function send(request) {
stopPlayback();
playbackError.value = '';
submittedPrompt.value = request.text || request.attachments.map(({ name }) => name).join(', ');
draft.value = { text: '' };
reply.value = '';
phase.value = 'responding';
announcement.value = 'Streaming sample reply.';
streamSample(replyChunks, reply, 400, finishReply);
}
/** Announces that the complete reply is available to read and play. */
function finishReply() {
phase.value = 'idle';
announcement.value = 'Sample reply ready.';
}
/** Stops this demo's reply playback and ignores any late speech events. */
function stopPlayback() {
if (!utterance) return;
utterance = undefined;
playing.value = false;
window.speechSynthesis.cancel();
}
/** Finishes the current utterance without altering the reply text. */
function finishPlayback(event) {
if (event.currentTarget !== utterance) return;
utterance = undefined;
playing.value = false;
if (event.type === 'error') playbackError.value = 'Playback failed. You can still read the reply.';
}
/** Reads the canned reply aloud with a local English voice when available. */
function togglePlayback() {
if (playing.value) {
stopPlayback();
return;
}
const speech = window.speechSynthesis;
const voice = speech?.getVoices().find((option) => option.localService && /^en(?:-|$)/i.test(option.lang));
if (!voice || !window.SpeechSynthesisUtterance) {
playbackError.value = 'A local English voice is unavailable in this browser.';
return;
}
playbackError.value = '';
utterance = new SpeechSynthesisUtterance(reply.value);
utterance.voice = voice;
utterance.lang = voice.lang;
utterance.onend = finishPlayback;
utterance.onerror = finishPlayback;
playing.value = true;
speech.speak(utterance);
}
/** Prompts the browser to load its voice list before the visitor can play a reply. */
function preparePlayback() {
window.speechSynthesis?.getVoices();
}
/** Releases scheduled sample events and any running playback on navigation. */
function dispose() {
clearTimeout(scheduledChunk);
stopPlayback();
}
onMounted(preparePlayback);
onBeforeUnmount(dispose);
</script>
<template>
<div class="w-full max-w-3xl space-y-3">
<DomAiInput
v-model="draft"
aria-label="Sample voice prompt"
placeholder="Try the microphone to fill in a sample prompt…"
:submit-disabled="phase === 'dictating'"
:submitting="phase === 'responding'"
@submit="send"
>
<template #actions="{ disabled }">
<DomIconButton
:label="micLabel"
:title="micLabel"
:icon="phase === 'dictating' ? 'M7 7h10v10H7z' : microphoneIcon"
:variant="phase === 'dictating' ? 'danger' : 'ghost'"
:disabled="disabled"
@click="toggleDictation"
/>
</template>
</DomAiInput>
<p role="status" class="sr-only">{{ announcement }}</p>
<p v-if="phase === 'dictating'" class="wrap-anywhere text-sm text-muted-fg">
{{ transcript || 'Simulating speech…' }}
</p>
<div v-if="submittedPrompt" class="space-y-3 rounded-xl border border-border bg-canvas p-4">
<div>
<p class="text-xs font-semibold text-muted-fg">You</p>
<p class="mt-1 whitespace-pre-wrap wrap-anywhere text-sm">{{ submittedPrompt }}</p>
</div>
<div class="space-y-2 border-t border-border pt-3">
<p class="text-xs font-semibold text-muted-fg">Sample assistant reply</p>
<p class="text-sm leading-6">{{ reply || 'Waiting for the first words…' }}</p>
<div v-if="phase !== 'responding'" class="flex flex-wrap items-center gap-x-3 gap-y-2">
<DomButton size="sm" variant="secondary" @click="togglePlayback">
{{ playing ? 'Stop playback' : 'Play sample reply' }}
</DomButton>
<p v-if="playbackError" role="status" class="text-xs text-muted-fg">{{ playbackError }}</p>
</div>
</div>
</div>
</div>
</template>
Attach from the media library
Open the media library with the plus button, select existing files, and attach their references to the prompt.
npm install @getdom/studio<script setup>
import '@getdom/studio/style.css';
import { computed, ref } from 'vue';
import { DomAiInput, DomButton, DomDialog, DomIconButton, DomMediaBrowser } from '@getdom/studio';
const library = [
{ ulid: 'asset-release', slug: 'documents', name: 'release-notes-cover.webp' },
{ ulid: 'asset-assistant', slug: 'ai', name: 'assistant-illustration.webp' },
{ ulid: 'asset-library', slug: 'files', name: 'media-library-icon.webp' },
].map(({ ulid, slug, name }) => ({
ulid,
name,
type: 'file',
path: `/${name}`,
file: { ulid, name, mimeType: 'image/webp', thumbnailUrl: `/media/product-icons-3d/${slug}.webp`, publicUrl: `/media/product-icons-3d/${slug}.webp` },
}));
const draft = ref({ text: '', media: [] });
const pickerOpen = ref(false);
const selectedKeys = ref([]);
const displayMode = ref('grid');
const request = ref(null);
const selected = computed(() => library.filter((item) => selectedKeys.value.includes(item.ulid)));
/** Opens the media picker with the draft's committed selection. */
function openPicker() {
selectedKeys.value = draft.value.media.map(({ id }) => id);
pickerOpen.value = true;
}
/** Copies stable media references into the draft after the user confirms. */
function attachSelection() {
draft.value = { ...draft.value, media: selected.value.map(({ ulid, name }) => ({ id: ulid, name })) };
pickerOpen.value = false;
}
/**
* Shows the media references that an application would resolve for a request.
* @param {import('@getdom/studio/vue').AiInputRequest} value Submitted composer request.
*/
function send(value) {
request.value = value;
draft.value = { text: '', media: [] };
}
</script>
<template>
<div class="w-full max-w-3xl space-y-3">
<DomAiInput v-model="draft" aria-label="Media library composer prompt" placeholder="Ask about the files you attach…" @submit="send">
<template #add="{ disabled }">
<DomIconButton label="Open media library" title="Open media library" aria-haspopup="dialog" :aria-expanded="pickerOpen" :disabled="disabled" @click="openPicker" />
</template>
</DomAiInput>
<DomDialog v-model="pickerOpen" title="Attach from the media library" width="min(94vw, 44rem)" height="min(86dvh, 33rem)">
<DomMediaBrowser
v-model:selected-keys="selectedKeys"
v-model:mode="displayMode"
:items="library"
:selectable-types="['file']"
:inspector="false"
:can-upload="false"
:can-create-folder="false"
:can-rename="false"
:can-move="false"
/>
<template #footer>
<span class="mr-auto text-sm text-muted-fg" aria-live="polite">{{ selected.length }} selected</span>
<DomButton size="sm" variant="secondary" data-close>Cancel</DomButton>
<DomButton size="sm" :disabled="!selected.length && !draft.media.length" @click="attachSelection">Use selection</DomButton>
</template>
</DomDialog>
<div v-if="request" role="status" class="rounded-lg border border-border bg-canvas p-3">
<p class="text-xs font-semibold text-muted-fg">Submitted request</p>
<pre class="mt-1 max-h-36 overflow-auto text-xs leading-5">{{ JSON.stringify(request, null, 2) }}</pre>
</div>
</div>
</template>
Connect an application
- Bind the draft with
v-model. Thesubmitevent includes the prompt, localFileobjects, and the selected settings. Clear the draft once the app accepts the request. - By default, Enter sends and Shift + Enter adds a line. Set
:submit-on-enter="false"to swap the shortcuts. - Enable
markdownfor inline formatting. At the start of a line, type-and a space for a bullet,[]and a space for a task, or#and a space for a heading. The request still carries Markdown text. Checking a task writes- [x]into that text. - The model picker uses
DomMenuStackinsideDomDropdown. Choose a model with settings to slide into its Features page. Back returns to the same model search. - Use
model-picker="flyout"for side menus. Setmodel-placement="trailing"to show the current reasoning effort near Send. - Put
<DomAudioControls compact>in theactionsslot for inline microphone capture. For live dictation, pass theMediaStreamfrom@streamto your transcription session. Show interim text as it arrives, merge final text into the draft, and finish the session when the stream becomesnull. - Bind
allow-empty-submitto whether the app has audio ready to send. Thesubmithandler can finish the recording and send it with the composer request. - Use
layout="workflow"to show the Plan and Build menu beside the attachment button. For an app-owned workflow control, use the toolbar layout with:mode-in-picker="false"and write its choice todraft.mode. - Replace the attachment trigger with the
addslot. Put existing library files indraft.mediato send their IDs and names alongside any local files. - Pass a model catalogue with each model’s supported workflow modes, reasoning efforts, and speeds. Use
autoFeaturesfor the options supported by automatic routing andresolvedModelLabelwhen the app knows which model Auto chose. - Put the default reasoning effort and speed first in their lists. Compatible draft preferences carry across models. If a model can’t use the draft’s workflow mode, select a supported mode before sending.
- The application handles uploads, routes the request to a provider, and validates the selected mode, reasoning effort, and speed.
Reference
Props
Control props
| Name | Type | TS | Default | Description |
|---|---|---|---|---|
modelValue | object | Record<string, unknown> | {} | Draft bound with v-model. Includes text, local attachments, media references, and execution settings. |
models | array | Array<unknown> | [] | Host-provided model catalogue. Auto is always available. |
autoFeatures | object | Record<string, unknown> | {} | Capabilities advertised by the application when Auto is selected. |
resolvedModelLabel | string | string | '' | Host-reported model to display when Auto is selected and its choice is known. |
layout | 'toolbar' | 'workflow' | string | 'toolbar' | The workflow layout shows a mode menu beside the attachment button. |
modeInPicker | boolean | boolean | true | Show the workflow mode in the model picker. Turn off when an application control sets draft.mode. |
modelPicker | 'stack' | 'flyout' | string | 'stack' | Use a sliding Features page or compact side flyouts for model settings. |
modelPlacement | 'leading' | 'trailing' | string | 'leading' | Place the model picker next to the attachment button or near Send, where it also shows the active reasoning effort. |
submitOnEnter | boolean | boolean | true | When enabled, Enter sends and Shift + Enter adds a line. Turn it off to swap the shortcuts. |
markdown | boolean | boolean | false | Format shortcuts as you type and submit the prompt as Markdown. |
placeholder | string | string | 'Ask AI…' | Hint shown in the empty prompt editor. |
ariaLabel | string | string | 'AI prompt' | Accessible name of the prompt editor. |
rows | number | number | 2 | Minimum number of text rows. |
maxRows | number | number | 8 | Maximum rows before scrolling. Use 0 for no limit. |
disabled | boolean | boolean | false | Disable the editor and its controls. |
submitting | boolean | boolean | false | Show progress and disable submission and toolbar controls while sending. |
submitDisabled | boolean | boolean | false | Disable sending while the host is preparing the request. |
allowEmptySubmit | boolean | boolean | false | Allow sending when the host supplies content outside the draft, such as a voice recording. |
Auto-generated from AI Input.props and inline _edit hints.
Events
| Name | Payload | Description |
|---|---|---|
| @update:modelValue | AiInputDraft | Emitted when the prompt, files, model, or execution settings change. |
| @submit | AiInputRequest | Emitted with the prompt, a snapshot of its files, and the current execution preferences. |
Names auto-detected from defineEmits and source emit() calls; payload and description from __doc.events when present.
Slots
| Name | Scope | Description |
|---|---|---|
| #add | { disabled } | Replace the native file picker trigger, for example with an application media library. |
| #tools | { disabled } | Application controls next to the attachment trigger, such as workflow or approval settings. |
| #actions | { disabled } | Additional controls immediately before the send button. |
Keyboard
- EnterSend from the editor. When submitOnEnter is false, insert a newline.
- Shift + EnterInsert a newline. When submitOnEnter is false, send from the editor.
- EscapeDismiss the workflow menu, model picker, or Features view.