Skip to main content

Примеры VERITY

VERITY — это живой автономный агент по адресу https://l402kit.com/api/verity. Эти примеры показывают, как программно вызывать все 10 сервисов с помощью агентского SDK l402-kit.

Настройка

import { L402Client } from "l402-kit/agent";
import { BlinkWallet } from "l402-kit/wallets";

const client = new L402Client({
  wallet: new BlinkWallet(process.env.BLINK_API_KEY!),
  budget: { maxSats: 5000 }, // hard cap per session
});

Получить все сервисы и текущие цены

const res = await fetch("https://l402kit.com/api/verity/services");
const { services } = await res.json();

for (const svc of services) {
  console.log(`${svc.id}: ${svc.price_sats} sats (floor: ${svc.floor_sats})`);
}

Проверить ежедневный финансовый отчёт

// Public — no payment required
const res = await fetch("https://l402kit.com/api/verity/fiscal");
const report = await res.json();

console.log(`Revenue: ${report.revenue_sats} sats (~${report.usd_equivalent})`);
console.log(`Net: ${report.net_sats} sats (${report.margin_pct}% margin)`);

for (const [service, data] of Object.entries(report.breakdown)) {
  console.log(`  ${service}: ${data.calls} calls × ${data.price} sats = ${data.revenue} sats`);
}

Состояние мира — 80 sats

Получить UTC-время, ваше местоположение и местную погоду в одном запросе.
const res = await client.fetch("https://l402kit.com/api/verity/worldstate");
const { time, location, weather } = await res.json();

console.log(`Time: ${time.utc}`);
console.log(`Location: ${location.city}, ${location.country}`);
console.log(`Weather: ${weather.temperature_c}°C, ${weather.condition}`);

Цена BTC — 10 sats

const res = await client.fetch("https://l402kit.com/api/verity/btc-price");
const { bitcoin } = await res.json();

console.log(`BTC: $${bitcoin.usd} USD | R$${bitcoin.brl} BRL`);

Веб-поиск — 100 sats

const res = await client.fetch(
  "https://l402kit.com/api/verity/search?q=bitcoin+lightning+l402",
);
const { results } = await res.json();

for (const r of results) {
  console.log(`${r.title}\n${r.link}\n${r.snippet}\n`);
}

Резюмирование — 50 sats

const longText = "..."; // up to 50,000 chars

const res = await client.fetch("https://l402kit.com/api/verity/summarize", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: longText, language: "english" }),
});
const { summary } = await res.json();
console.log(summary);

Тональность — 30 sats

const res = await client.fetch("https://l402kit.com/api/verity/sentiment", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: "Lightning payments are instant and cheap!" }),
});
const { analysis } = await res.json();
// { sentiment: "positive", score: 0.94, confidence: 0.91, keywords: [...] }

Разведка домена — 500 sats

const res = await client.fetch(
  "https://l402kit.com/api/verity/domain-intel?domain=bitcoin.org",
);
const { whois, dns, certificates } = await res.json();

console.log(`Registered: ${whois.registered}`);
console.log(`Expires: ${whois.expires}`);
console.log(`A records: ${dns.a_records.join(", ")}`);

Веб-скрейпинг — 200 sats

const res = await client.fetch("https://l402kit.com/api/verity/scrape", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://bitcoin.org/en/bitcoin-paper" }),
});
const { content, title } = await res.json();
console.log(`${title}\n\n${content.slice(0, 500)}...`);

Перевод — 50 sats

Переводите любой текст на 11 локалей. Режим с поддержкой MDX сохраняет блоки кода, теги компонентов, URL и терминологию L402.
// Обычный текст
const res = await client.fetch("https://l402kit.com/api/verity/translate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    text: "Pay per call with Bitcoin Lightning. No API keys needed.",
    locale: "pt",
  }),
});
const { translated } = await res.json();
console.log(translated);
// "Pague por chamada com Bitcoin Lightning. Nenhuma chave de API necessária."
// MDX-aware (preserves code blocks, <Components />, URLs)
const mdxPage = `## Install\n\`\`\`bash\nnpm install l402-kit\n\`\`\`\nSee [docs](https://docs.l402kit.com).`;

const res = await client.fetch("https://l402kit.com/api/verity/translate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: mdxPage, locale: "es", format: "mdx" }),
});
const { translated } = await res.json();
// Code block and URL preserved intact; only prose translated
Поддерживаемые локали: pt es zh ar fr de ja ko hi ru it

Интеграция l402-kit — 10 000 sats

Отправьте VERITY публичный репозиторий GitHub. Она прочитает код и вернёт готовую интеграцию l402-kit.
const res = await client.fetch("https://l402kit.com/api/verity/integration", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ repoUrl: "https://github.com/owner/my-api" }),
});
const { integration, next_steps } = await res.json();

// integration = markdown with exact code to add to your repo
console.log(integration);
Сервис интеграции стоит 10 000 sats (~$10). После оплаты вы получаете готовый код middleware, специфичный для вашего фреймворка (Express, FastAPI, Gin, Axum и др.) — а VERITY получает первый реферал на ваш новый API с поддержкой l402-kit.

Цепочки сервисов

Распространённый паттерн агента: поиск → скрейпинг → резюмирование.
// 1. Поиск по теме (100 sats)
const searchRes = await client.fetch(
  "https://l402kit.com/api/verity/search?q=bitcoin+lightning+adoption+2026",
);
const { results } = await searchRes.json();
const topUrl = results[0].link;

// 2. Скрейпинг первого результата (200 sats)
const scrapeRes = await client.fetch("https://l402kit.com/api/verity/scrape", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: topUrl }),
});
const { content } = await scrapeRes.json();

// 3. Резюмирование статьи (50 sats)
const sumRes = await client.fetch("https://l402kit.com/api/verity/summarize", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: content }),
});
const { summary } = await sumRes.json();

// Общая стоимость: 350 sats (~$0.35)
console.log(summary);

Python

from l402kit import L402Client, BlinkWallet
import os

client = L402Client(
    wallet=BlinkWallet(os.environ["BLINK_API_KEY"]),
    budget={"max_sats": 5000},
)

# World state
resp = client.get("https://l402kit.com/api/verity/worldstate")
data = resp.json()
print(f"{data['time']['utc']} | {data['location']['city']} | {data['weather']['temperature_c']}°C")