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.

1.1 KB
Raw Blame
import { sql } from '../../../_lib/db.js';
import { cors, json, method, wrap, error, rateLimited } from '../../../_lib/http.js';
import { limits, clientIp } from '../../../_lib/rate-limit.js';

// GET /api/agents/:id/pricing — public for all agents (x402 manifest reads this)
export default wrap(async (req, res) => {
	if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;
	if (!method(req, res, ['GET'])) return;

	const parts = new URL(req.url, 'http://x').pathname.split('/').filter(Boolean);
	const id = parts[2];
	if (!id) return error(res, 400, 'bad_request', 'missing agent id');

	const rl = await limits.pricingPerIp(clientIp(req));
	if (!rl.success) return rateLimited(res, rl);

	const [agent] = await sql`
		SELECT id FROM agent_identities WHERE id = ${id} AND deleted_at IS NULL
	`;
	if (!agent) return error(res, 404, 'not_found', 'agent not found');

	const prices = await sql`
		SELECT id, skill, currency_mint, chain, amount, is_active
		FROM agent_skill_prices
		WHERE agent_id = ${id} AND is_active = true
		ORDER BY skill
	`;

	return json(res, 200, { prices });
});