Docs›Quickstart
Quickstart
Install the SDK, get your API key, and protect your first request in under 5 minutes.
Install the SDK
Install @grepture/sdk with your package manager of choice:
npm install @grepture/sdk
Or with pnpm, yarn, or bun:
pnpm add @grepture/sdk
bun add @grepture/sdk
Get your API key
- Sign up at grepture.com/en/pricing — the free plan includes 1,000 requests/month and 25 AI detection requests/month
- Open the dashboard and navigate to the API page in the sidebar
- Copy your API key (format:
gpt_...)
Store the key in your environment:
export GREPTURE_API_KEY=gpt_your_key_here
Create a Grepture client
Import the Grepture class and create an instance with your API key and proxy URL:
import { Grepture } from "@grepture/sdk";
const grepture = new Grepture({
apiKey: process.env.GREPTURE_API_KEY!,
proxyUrl: "https://proxy.grepture.com",
});
Wrap your OpenAI client
Use grepture.clientOptions() to get configuration for your OpenAI client. Pass your OpenAI API key and base URL — Grepture proxies the request, applying your detection rules before it reaches OpenAI.
import OpenAI from "openai";
import { Grepture } from "@grepture/sdk";
const grepture = new Grepture({
apiKey: process.env.GREPTURE_API_KEY!,
proxyUrl: "https://proxy.grepture.com",
});
const openai = new OpenAI({
...grepture.clientOptions({
apiKey: process.env.OPENAI_API_KEY!,
baseURL: "https://api.openai.com/v1",
}),
});
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello, world!" }],
});
This works with any OpenAI-compatible provider — just change the baseURL and apiKey to match your provider.
Protect any HTTP call
For non-SDK traffic, use grepture.fetch() as a drop-in replacement for fetch:
import { Grepture } from "@grepture/sdk";
const grepture = new Grepture({
apiKey: process.env.GREPTURE_API_KEY!,
proxyUrl: "https://proxy.grepture.com",
});
const response = await grepture.fetch("https://api.example.com/data", {
method: "POST",
body: JSON.stringify({ message: "Hello from my app" }),
});
const data = await response.json();
The returned GreptureResponse wraps a standard Response and adds requestId, rulesApplied, and aiSampling properties so you can see what happened.
Verify it works
After making your first request, open the Grepture dashboard. You should see:
- The request logged in the Traffic Log page
- Any detected PII or secrets highlighted with the action taken (redact, mask, block, or log)
- Stats updated on the Dashboard overview
Just need observability? Use trace mode
The setup above routes traffic through the Grepture proxy, which enables PII redaction, blocking, and prompt management. If you only need observability and cost tracking — without the proxy hop — use trace mode:
const grepture = new Grepture({
apiKey: process.env.GREPTURE_API_KEY!,
proxyUrl: "https://proxy.grepture.com",
mode: "trace",
});
Requests go directly to the provider. The SDK captures metadata (tokens, model, latency, cost) asynchronously and sends it to your dashboard. Same traffic log, same cost tracking — zero latency overhead.
In serverless environments, call flush() before the function exits:
await grepture.flush();
See Operating modes in the SDK reference for details.
What's next
- SDK Reference — full API surface, operating modes, error handling, and TypeScript types
- Configuration — detection rules, custom patterns, and zero-data mode
- Dashboard — traffic monitoring, rule management, and billing