DocsQuickstart

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

  1. Sign up at grepture.com/en/pricing — the free plan includes 1,000 requests/month and 25 AI detection requests/month
  2. Open the dashboard and navigate to the API page in the sidebar
  3. 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

What's next

  • SDK Reference — full API surface, error handling, and TypeScript types
  • Configuration — detection rules, custom patterns, and zero-data mode
  • Dashboard — traffic monitoring, rule management, and billing