Welcome to Toon Agent Bridge! This guide will help you get started with converting your OpenAPI or agents.json schemas into agent-ready workflows.
npm install @programsmagic/toon-core @programsmagic/toon-backend-node @programsmagic/toon-frontend
# or
pnpm add @programsmagic/toon-core @programsmagic/toon-backend-node @programsmagic/toon-frontend
pip install toon-backend-python
import { createServer } from '@programsmagic/toon-backend-node';
const server = await createServer({
port: 3000,
schemaSource: './openapi.json',
cors: true,
});
await server.start();
import { AgentVisualizer } from '@programsmagic/toon-frontend';
import '@programsmagic/toon-frontend/styles';
function App() {
return (
<AgentVisualizer
url="http://localhost:3000/events"
protocol="sse"
autoConnect={true}
/>
);
}
from toon_backend import create_server, ServerOptions
options = ServerOptions(
schema_source="./schema.json",
port=8000,
cors=True,
)
server = await create_server(options)
# Use with uvicorn or your ASGI server
Convert your existing OpenAPI schema into an agent-ready API:
import { createServer } from '@programsmagic/toon-backend-node';
const server = await createServer({
port: 3000,
schemaSource: './openapi.json',
cors: true,
});
await server.start();
console.log('Server running at http://localhost:3000');
Visualize agent events in real-time with React:
import { AgentVisualizer } from '@programsmagic/toon-frontend';
import '@programsmagic/toon-frontend/styles';
function App() {
return (
<AgentVisualizer
url="http://localhost:3000/events"
protocol="sse"
autoConnect={true}
showTimeline={true}
showFlowDiagram={true}
/>
);
}
Optimize your data for LLM interactions:
import { encodeToon } from '@programsmagic/toon-format';
import { countTokensInData } from '@programsmagic/toon-tokenizer';
const data = { users: [...] };
const toon = encodeToon(data, { minimize: true });
const tokens = countTokensInData(toon, 'gpt-4');
console.log(`Token count: ${tokens.tokens}`);
console.log(`Estimated cost: $${tokens.estimatedCost.total}`);
Convert between JSON, TOON, CSV, and YAML:
import { convert } from '@programsmagic/toon-converter';
const json = '{"user": {"id": 123, "name": "Ada"}}';
const toon = await convert(json, 'json', 'toon');
console.log(toon); // user id 123 name Ada
Problem: Server fails to start with port already in use error.
Solution:
port: 3001lsof -ti:3000 | xargs killProblem: Error “Schema file not found”.
Solution:
schemaSource: path.join(__dirname, './schema.json')schemaSource: './schemas/openapi.json'Problem: CORS errors in browser console.
Solution:
cors: truecors: { origin: ['http://localhost:3000'] }Problem: Events not appearing in frontend.
Solution:
curl http://localhost:3000/healthcurl http://localhost:3000/eventsprotocol="sse" or protocol="websocket"A: OpenAPI is a standard API specification format. agents.json is an extension that adds agent-specific features like flows and links. You can use either format with Toon Agent Bridge.
A: Yes! Point to your existing OpenAPI schema and Toon Agent Bridge will automatically create agent-ready endpoints with event streaming.
A: No! Toon Agent Bridge works as a bridge layer. Your existing API code remains unchanged.
A: We support GPT-3.5, GPT-4, Claude 3, and more. See the Token Optimization Guide for the full list.
A: Yes! All packages are production-ready with proper error handling, TypeScript types, and comprehensive testing.
A: See our Contributing Guide for details on how to contribute.