Blog Demo Join Waitlist
Back to blog

From OpenAPI Spec to In-App Copilot in 60 Minutes

tutorial openapi engineering

TL;DR: If you have an OpenAPI spec (or GraphQL schema) and a React app, you can go from zero to a working in-app copilot in about an hour. Here's how it works.

Ship an in-app agent in a day

Get early access to Agent Koan and give your users a copilot that actually does things.

Join the Waitlist

What you need

Before you start:

That last one matters. Agent Koan executes API calls as the end user, not as a service account. The copilot inherits all your existing permission logic (RBAC, tenant isolation, feature flags) without you writing any new authorization rules.

Step 1: Create a project (5 minutes)

Sign in to the Agent Koan dashboard and create a new project. Give it a name (e.g., "Acme CRM") and paste your OpenAPI spec URL or upload the JSON file.

Agent Koan parses the spec and generates a tool catalog: one tool per endpoint, grouped by tag. Each tool gets a name, description, parameter schema, and a default risk level based on the HTTP method:

Method Default risk
GET Low
POST Medium
PUT Medium
PATCH Medium
DELETE High

You can override any of these in the dashboard.

Step 2: Configure your tools (15 minutes)

This is where you decide what the copilot can and can't do.

Enable endpoints. Everything is disabled by default. Toggle on the ones you want the copilot to access. Start small: maybe 5 read endpoints and 1-2 write endpoints.

Set risk levels. For each tool:

Add constraints. You can add parameter constraints per tool: enum restrictions, max lengths, required fields. For example, you might restrict CreateOpportunity so that stage can only be "Prospecting" or "Qualification".

Edit descriptions. The auto-generated descriptions are usually fine, but you can tweak them. Better descriptions mean better tool selection.

Step 3: Set up auth (15 minutes)

Agent Koan needs a way to get a user-scoped token for each session. The simplest approach:

  1. Create a backend endpoint (e.g., POST /api/agent-koan-token)
  2. This endpoint authenticates the current user (from your session/cookie)
  3. It mints a short-lived JWT with the user's ID, tenant ID, and scopes
  4. Returns it as plain text
// Example: Express.js
app.post('/api/agent-koan-token', requireAuth, (req, res) => {
  const token = jwt.sign(
    { sub: req.user.id, tenant: req.user.tenantId },
    process.env.AGENT_KOAN_SECRET,
    { expiresIn: '15m' }
  );
  res.send(token);
});

Step 4: Embed the widget (10 minutes)

Install the SDK:

npm install @agentkoan/widget

Add the component to your app:

import { AgentKoan } from '@agentkoan/widget'

function App() {
  return (
    <div>
      {/* Your existing app */}
      <AgentKoan
        projectId="proj_abc123"
        getUserToken={() =>
          fetch('/api/agent-koan-token', { method: 'POST' })
            .then(r => r.text())
        }
      />
    </div>
  )
}

That's it. The widget handles the conversation UI, tool selection, confirmation flows, and execution.

Step 5: Test and ship (15 minutes)

Open your app in staging. Click the copilot widget and try a few things:

Check the dashboard logs to see every tool call, its parameters, status code, and latency.

When it looks good, ship to production. You can start in read-only mode and turn on write actions gradually.

What's next

Once the basic integration is working:

You don't need to build agent infrastructure from scratch. Your API exists. Your auth works. Agent Koan connects the two and adds the guardrails.

Join the waitlist →

Ship an in-app agent in a day

Get early access to Agent Koan and give your users a copilot that actually does things.

Join the Waitlist