Quickstart - API Monitoring Setup
1. Create a project
Sign up at kohicorp.com and create a project. You get a project key and secret key.
2. Set up the SDK
You can use the setup wizard or do it manually.
Wizard (recommended)
Run this in your project directory and follow the prompts. It detects your framework, installs the right SDK, and configures your credentials.
npx @kohicorp/wizardThe wizard supports Express, Next.js, FastAPI, Flask, net/http, and fasthttp. Once it finishes you can skip straight to deploying.
Manual setup
Install
npm install kohi-node dotenvnpm install kohi-nodepip install kohi-python python-dotenvpip install kohi-python python-dotenvgo get github.com/kohicorp/kohi-gogo get github.com/kohicorp/kohi-goAdd your keys
Add to .env (or .env.local for Next.js):
KOHI_PROJECT_KEY=pk_your_project_keyKOHI_SECRET_KEY=your_secret_keyInitialize
Must be the first middleware, before express.json(), cors(), or any routes.
require("dotenv").config();const express = require("express");const { init } = require("kohi-node");
const app = express();const { expressMiddleware } = init({ projectKey: process.env.KOHI_PROJECT_KEY, secretKey: process.env.KOHI_SECRET_KEY,});
app.use(expressMiddleware());app.use(express.json());// ... your routesCreate instrumentation.ts in your project root. Next.js 14+ picks it up automatically.
export async function register() { if (process.env.NEXT_RUNTIME === "nodejs") { const { instrumentNextJs } = await import("kohi-node"); instrumentNextJs({ projectKey: process.env.KOHI_PROJECT_KEY!, secretKey: process.env.KOHI_SECRET_KEY!, }); }}Monitor() must be right after app = FastAPI() and before any route definitions.
import osfrom dotenv import load_dotenvfrom fastapi import FastAPIfrom kohi import Monitor
load_dotenv()
app = FastAPI()
monitor = Monitor( app, project_key=os.getenv("KOHI_PROJECT_KEY"), secret_key=os.getenv("KOHI_SECRET_KEY"),)Monitor() must be right after app = Flask(__name__) and before any route definitions.
import osfrom dotenv import load_dotenvfrom flask import Flaskfrom kohi import Monitor
load_dotenv()
app = Flask(__name__)
monitor = Monitor( app, project_key=os.getenv("KOHI_PROJECT_KEY"), secret_key=os.getenv("KOHI_SECRET_KEY"),)Wrap your mux with kohi.NetHTTPMiddleware(monitor) as the outermost layer.
import kohi "github.com/kohicorp/kohi-go"
monitor, err := kohi.New(kohi.Config{ ProjectKey: os.Getenv("KOHI_PROJECT_KEY"), SecretKey: os.Getenv("KOHI_SECRET_KEY"),})if err != nil { log.Fatal(err) }defer monitor.Close()
mux := http.NewServeMux()// ... your routeshttp.ListenAndServe(":8080", kohi.NetHTTPMiddleware(monitor)(mux))Wrap your handler with kohi.FastHTTPMiddleware(monitor) as the outermost layer.
import kohi "github.com/kohicorp/kohi-go"
monitor, err := kohi.New(kohi.Config{ ProjectKey: os.Getenv("KOHI_PROJECT_KEY"), SecretKey: os.Getenv("KOHI_SECRET_KEY"),})if err != nil { log.Fatal(err) }defer monitor.Close()
handler := kohi.FastHTTPMiddleware(monitor)(yourHandler)fasthttp.ListenAndServe(":8080", handler)3. Deploy
Deploy your app. Requests and errors start appearing in your dashboard within seconds.