Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix: mark subproject as dirty to indicate uncommitted changes

nirholas5712db7771e1
diff --git a/api/chat/models.js b/api/chat/models.js
new file mode 100644
index 000000000..8b8161746
--- /dev/null
+++ b/api/chat/models.js
@@ -0,0 +1,44 @@
+import { env } from '../_lib/env.js';
+import { cors, json, method, wrap, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+
+// Cache the fetched model list for 5 minutes to avoid hammering OpenRouter.
+let cachedModels = null;
+let cacheExpiresAt = 0;
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rl = await limits.publicIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'Too many requests — try again shortly');
+
+ if (!env.OPENROUTER_API_KEY)
+ return json(res, 200, { data: [] });
+
+ const now = Date.now();
+ if (cachedModels && now < cacheExpiresAt) {
+ return json(res, 200, { data: cachedModels });
+ }
+
+ const upstream = await fetch('https://openrouter.ai/api/v1/models', {
+ headers: {
+ Authorization: `Bearer ${env.OPENROUTER_API_KEY}`,
+ 'HTTP-Referer': 'https://three.ws',
+ 'X-Title': 'three.ws chat',
+ },
+ });
+
+ if (!upstream.ok)
+ return json(res, 200, { data: [] });
+
+ const { data: allModels } = await upstream.json();
+
+ // Only expose free-tier models so completions work via the proxy without a user key.
+ const freeModels = (allModels ?? []).filter((m) => m.id.endsWith(':free'));
+
+ cachedModels = freeModels;
+ cacheExpiresAt = now + 5 * 60 * 1000;
+
+ return json(res, 200, { data: freeModels });
+});
diff --git a/api/chat/proxy.js b/api/chat/proxy.js
index fdaf67ac8..7cd96ca35 100644
--- a/api/chat/proxy.js
+++ b/api/chat/proxy.js
@@ -2,19 +2,6 @@ import { env } from '../_lib/env.js';
import { cors, error, method, wrap, readJson } from '../_lib/http.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
-// Only allow free-tier OpenRouter models to prevent abuse.
-const FREE_MODELS = new Set([
- 'meta-llama/llama-3.3-70b-instruct:free',
- 'meta-llama/llama-3.2-3b-instruct:free',
- 'google/gemma-3-27b-it:free',
- 'google/gemma-3-12b-it:free',
- 'openai/gpt-oss-120b:free',
- 'openai/gpt-oss-20b:free',
- 'qwen/qwen3-coder:free',
- 'qwen/qwen3-next-80b-a3b-instruct:free',
- 'nousresearch/hermes-3-llama-3.1-405b:free',
-]);
-
export default wrap(async (req, res) => {
if (cors(req, res, { methods: 'POST,OPTIONS' })) return;
if (!method(req, res, ['POST'])) return;
@@ -33,8 +20,9 @@ export default wrap(async (req, res) => {
}
const model = body?.model;
- if (!model || !FREE_MODELS.has(model))
- return error(res, 400, 'invalid_model', `Model not allowed. Use one of: ${[...FREE_MODELS].join(', ')}`);
+ // Only allow free-tier OpenRouter models to prevent abuse.
+ if (!model || !model.endsWith(':free'))
+ return error(res, 400, 'invalid_model', 'Only free-tier models (ending in :free) are allowed via the built-in proxy');
const upstream = await fetch('https://openrouter.ai/api/v1/chat/completions', {
method: 'POST',
diff --git a/chat/src/App.svelte b/chat/src/App.svelte
index b728c6d38..b57f1d060 100644
--- a/chat/src/App.svelte
+++ b/chat/src/App.svelte
@@ -1234,14 +1234,30 @@
}
loading = true;
- models = await fetchModels({
- onFinally: () => {
- loading = false;
- },
- });
- // Always prepend built-in free models so they're available without any API key
- models = [...BUILTIN_MODELS, ...models];
+ // Fetch all free models from the server (no user API key needed) alongside user's provider models
+ const [serverFreeModels, userModels] = await Promise.all([
+ fetch('/api/chat/models')
+ .then((r) => r.json())
+ .then(({ data }) =>
+ (data ?? []).map((m) => ({
+ id: m.id,
+ name: m.name,
+ provider: 'Built-in',
+ modality: 'text->text',
+ }))
+ )
+ .catch(() => []),
+ fetchModels({
+ onFinally: () => {
+ loading = false;
+ },
+ }),
+ ]);
+
+ // Merge: server free models first (deduplicated), then user's API-key models
+ const seenIds = new Set(serverFreeModels.map((m) => m.id));
+ models = [...serverFreeModels, ...userModels.filter((m) => !seenIds.has(m.id))];
// Auto-select default built-in model if no model chosen yet, or if the saved model no longer exists
const savedModelStillValid = convo.models?.[0]?.id && models.some((m) => m.id === convo.models[0].id);
diff --git a/chat/src/providers.js b/chat/src/providers.js
index b2c588975..5d7528ecf 100644
--- a/chat/src/providers.js
+++ b/chat/src/providers.js
@@ -235,7 +235,15 @@ const capabilities = {
};
export async function fetchModels({ onFinally }) {
+ const openrouterProvider = providers.find((p) => p.name === 'OpenRouter');
+
try {
+ // Always fetch server-proxied free models so they appear without a user API key.
+ const serverModelsPromise = fetch('/api/chat/models')
+ .then((r) => r.json())
+ .then((json) => openrouterProvider.responseMapperFn(json))
+ .catch(() => []);
+
const promises = providers.map((provider) => {
const apiKey = provider.apiKeyFn();
if (apiKey === '' || !provider.modelsUrl) {
@@ -262,8 +270,11 @@ export async function fetchModels({ onFinally }) {
});
});
- const results = await Promise.all(promises);
- const externalModels = results.flat();
+ const [serverModels, ...providerResults] = await Promise.all([serverModelsPromise, ...promises]);
+ // User's own provider keys take precedence — deduplicate by id.
+ const userModels = providerResults.flat();
+ const userModelIds = new Set(userModels.map((m) => m.id));
+ const externalModels = [...userModels, ...serverModels.filter((m) => !userModelIds.has(m.id))];
function getPriorityIndex(model) {
for (let i = 0; i < priorityOrder.length; i++) {
diff --git a/public/chat/index.html b/public/chat/index.html
index 832f807f9..87e79d6af 100644
--- a/public/chat/index.html
+++ b/public/chat/index.html
@@ -43,7 +43,7 @@
}
}
</script>
- <script type="module" crossorigin src="/chat/assets/index-Dewa3DP4.js"></script>
+ <script type="module" crossorigin src="/chat/assets/index-iMav3Mur.js"></script>
<link rel="stylesheet" crossorigin href="/chat/assets/index-Ciwx7Aa1.css">
</head>
<body>
diff --git a/vercel.json b/vercel.json
index cf711fc47..767003178 100644
--- a/vercel.json
+++ b/vercel.json
@@ -223,6 +223,12 @@
{ "src": "/discover/", "dest": "/discover/index.html" },
{ "src": "/discover/(.*)", "dest": "/discover/$1" },
+ { "src": "/api/skills/categories", "dest": "/api/skills/categories" },
+ { "src": "/api/skills/([^/]+)/install", "dest": "/api/skills/[id]/install?id=$1" },
+ { "src": "/api/skills/([^/]+)/rate", "dest": "/api/skills/[id]/rate?id=$1" },
+ { "src": "/api/skills/([^/]+)", "dest": "/api/skills/[id]?id=$1" },
+ { "src": "/api/skills", "dest": "/api/skills/index" },
+
{ "src": "/api/(.*)", "dest": "/api/$1" },
{