Skip to content

AI-native design editor. Open-source Figma alternative.

Add model selector with curated list (Claude, Gemini, GPT, DeepSeek, Llama)

Danila Poyarkovf0c482ac5c15
diff --git a/components.d.ts b/components.d.ts
index 8f50d2a5d..3978490b6 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -36,6 +36,7 @@ declare module 'vue' {
IconLucideBaseline: typeof import('~icons/lucide/baseline')['default']
IconLucideBlend: typeof import('~icons/lucide/blend')['default']
IconLucideBold: typeof import('~icons/lucide/bold')['default']
+ IconLucideBot: typeof import('~icons/lucide/bot')['default']
IconLucideCheck: typeof import('~icons/lucide/check')['default']
IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']
IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']
diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vue
index b15af4c20..5e03c7f7a 100644
--- a/src/components/ChatPanel.vue
+++ b/src/components/ChatPanel.vue
@@ -7,6 +7,13 @@ import {
ScrollAreaScrollbar,
ScrollAreaThumb,
ScrollAreaViewport,
+ SelectContent,
+ SelectItem,
+ SelectPortal,
+ SelectRoot,
+ SelectTrigger,
+ SelectValue,
+ SelectViewport,
TooltipContent,
TooltipPortal,
TooltipProvider,
@@ -17,12 +24,12 @@ import { computed, nextTick, ref, watch } from 'vue'
import { Markdown } from 'vue-stream-markdown'
import 'vue-stream-markdown/index.css'
-import { useAIChat } from '@/composables/use-chat'
+import { MODELS, useAIChat } from '@/composables/use-chat'
import type { DesignMessage } from '@/composables/use-chat'
import type { Chat } from '@ai-sdk/vue'
-const { apiKey, isConfigured, createChat } = useAIChat()
+const { apiKey, modelId, isConfigured, createChat } = useAIChat()
const chat = ref<Chat<DesignMessage> | null>(null)
const input = ref('')
@@ -280,6 +287,43 @@ function toolState(part: ToolPart): 'pending' | 'done' | 'error' {
<!-- Input -->
<TooltipProvider>
<div class="shrink-0 border-t border-border px-3 py-2">
+ <!-- Model selector -->
+ <div class="mb-1.5 flex items-center">
+ <SelectRoot v-model="modelId">
+ <SelectTrigger
+ class="flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted hover:bg-hover hover:text-surface"
+ >
+ <icon-lucide-bot class="size-3" />
+ <SelectValue />
+ <icon-lucide-chevron-down class="size-2.5" />
+ </SelectTrigger>
+ <SelectPortal>
+ <SelectContent
+ position="popper"
+ side="top"
+ :side-offset="4"
+ class="z-50 max-h-60 overflow-y-auto rounded-lg border border-border bg-panel p-1 shadow-lg"
+ >
+ <SelectViewport>
+ <SelectItem
+ v-for="model in MODELS"
+ :key="model.id"
+ :value="model.id"
+ class="flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-[11px] text-surface outline-none data-[highlighted]:bg-hover"
+ >
+ <span class="flex-1">{{ model.name }}</span>
+ <span
+ v-if="model.tag"
+ class="rounded bg-accent/10 px-1 py-px text-[9px] text-accent"
+ >
+ {{ model.tag }}
+ </span>
+ </SelectItem>
+ </SelectViewport>
+ </SelectContent>
+ </SelectPortal>
+ </SelectRoot>
+ </div>
<form class="flex gap-1.5" @submit="handleSubmit">
<input
v-model="input"
diff --git a/src/composables/use-chat.ts b/src/composables/use-chat.ts
index e4064cfba..1c025763d 100644
--- a/src/composables/use-chat.ts
+++ b/src/composables/use-chat.ts
@@ -6,8 +6,72 @@ import { computed, ref, watch } from 'vue'
import type { InferAgentUIMessage } from 'ai'
const API_KEY_STORAGE = 'open-pencil:openrouter-api-key'
+const MODEL_STORAGE = 'open-pencil:model'
+
+export interface ModelOption {
+ id: string
+ name: string
+ provider: string
+ tag?: string
+}
+
+export const MODEL_OPTIONS: ModelOption[] = [
+ // Design-optimized (vision + tool calling + strong spatial reasoning)
+ {
+ id: 'anthropic/claude-sonnet-4',
+ name: 'Claude Sonnet 4',
+ provider: 'Anthropic',
+ tag: 'Recommended'
+ },
+ { id: 'anthropic/claude-opus-4', name: 'Claude Opus 4', provider: 'Anthropic', tag: 'Smartest' },
+ {
+ id: 'google/gemini-2.5-pro-preview-06-05',
+ name: 'Gemini 2.5 Pro',
+ provider: 'Google',
+ tag: 'Long context'
+ },
+ { id: 'openai/gpt-4.1', name: 'GPT-4.1', provider: 'OpenAI' },
+
+ // Fast & cheap
+ { id: 'anthropic/claude-sonnet-4', name: 'Claude Sonnet 4', provider: 'Anthropic' },
+ {
+ id: 'google/gemini-2.5-flash-preview-05-20',
+ name: 'Gemini 2.5 Flash',
+ provider: 'Google',
+ tag: 'Fast'
+ },
+ { id: 'openai/gpt-4.1-mini', name: 'GPT-4.1 Mini', provider: 'OpenAI', tag: 'Cheap' },
+
+ // Open source
+ {
+ id: 'deepseek/deepseek-chat-v3-0324:free',
+ name: 'DeepSeek V3',
+ provider: 'DeepSeek',
+ tag: 'Free'
+ },
+ {
+ id: 'meta-llama/llama-3.3-70b-instruct:free',
+ name: 'Llama 3.3 70B',
+ provider: 'Meta',
+ tag: 'Free'
+ }
+]
+
+// Deduplicate by id, keeping first occurrence
+const seen = new Set<string>()
+const deduped: ModelOption[] = []
+for (const m of MODEL_OPTIONS) {
+ if (!seen.has(m.id)) {
+ seen.add(m.id)
+ deduped.push(m)
+ }
+}
+export const MODELS = deduped
+
+export const DEFAULT_MODEL = MODELS[0].id
const apiKey = ref(localStorage.getItem(API_KEY_STORAGE) ?? '')
+const modelId = ref(localStorage.getItem(MODEL_STORAGE) ?? DEFAULT_MODEL)
const activeTab = ref<'design' | 'ai'>('design')
watch(apiKey, (key) => {
@@ -18,6 +82,10 @@ watch(apiKey, (key) => {
}
})
+watch(modelId, (id) => {
+ localStorage.setItem(MODEL_STORAGE, id)
+})
+
const isConfigured = computed(() => apiKey.value.length > 0)
function createAgent() {
@@ -30,7 +98,7 @@ function createAgent() {
})
return new ToolLoopAgent({
- model: openrouter('anthropic/claude-sonnet-4'),
+ model: openrouter(modelId.value),
instructions:
'You are a design assistant inside OpenPencil, a Figma-like design editor. ' +
'Help users create and modify designs. Be concise and direct.'
@@ -53,6 +121,7 @@ function createChat() {
export function useAIChat() {
return {
apiKey,
+ modelId,
activeTab,
isConfigured,
createChat