Quickstart
Use It Now
Run one complete call chain with the default database, AdminClient, and UserClient.
If you want the quickest hands-on route, use the ready-made product project:
products/serverproducts/client
Inside those product directories, the example flow is still the fastest way to verify Base, product creation, user_token, and UserClient together.
After it works, the flow looks like this:
Product Client
↓ AdminClient creates product / issues user_token
VisibleBase Base
↓ UserClient calls a service with user_token + product_id
service.default() fills query fallback + match()1. Start Base
import { Base } from "@visiblebase/base";
const base = new Base();
base.text()
.default({ model: "gpt-5.4" })
.handle(async (ctx) => {
return {
id: crypto.randomUUID(),
role: "assistant",
parts: [
{
type: "text",
text: `Echo: ${ctx.query.prompt}`,
state: "done",
},
],
};
});
await base.serve({
host: "127.0.0.1",
port: 3001,
});Then write one model record into the default database:
INSERT INTO visiblebase_models (
model_id,
name,
provider,
upstream_model,
description,
is_primary,
status,
config_json,
created_at,
updated_at
) VALUES (
'gpt-5.4',
'GPT-5.4',
'openai',
'gpt-5.4',
'Primary text model',
'true',
'active',
'{}',
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
);2. Create a product and issue a token
import { AdminClient } from "@visiblebase/client";
const admin = new AdminClient({
base_url: "http://127.0.0.1:3001",
admin_secret_key: process.env.VISIBLEBASE_ADMIN_SECRET_KEY,
});
const product = await admin.products.create({
name: "Demo Product",
});
const user = await admin.tokens.apply({
product_id: product.product_id,
user_id: "user_123",
metadata: {
plan: "pro",
},
ttl: "7d",
});3. Call Base from the product
import { UserClient } from "@visiblebase/client";
const client = new UserClient({
base_url: "http://127.0.0.1:3001",
product_id: product.product_id,
user_token: user.user_token,
});
const models = await client.models();
const result = await client.text({
model: models.primary(),
prompt: "Hello VisibleBase",
});4. What exactly gets reused
When more products connect, the shared layer is:
- provider keys in
.env - the model directory in the database
user_tokenverification- service routing logic
- hooks for plan, quota, logging, and billing
Next: