← Quickstart

TypeScript quickstart

From a fresh repo to a working proxy call in 4 steps. Node ≥ 20 or any modern runtime with fetch.

1. Install

npm install edgify
# or: pnpm add edgify   |   bun add edgify

2. Configure

// edgify.ts
const EDGIFY_API = "https://api.edgify.net";
const EDGIFY_TOKEN = process.env.EDGIFY_TOKEN!; // service-account JWT

3. Mint a virtual key

const res = await fetch(`${EDGIFY_API}/api/virtual-keys`, {
  method: "POST",
  headers: {
    authorization: `Bearer ${EDGIFY_TOKEN}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    name: "ts-quickstart",
    provider_key_id: "<your provider_key_id>",
    limit_profile_id: "<your limit_profile_id>",
  }),
});

const { token_one_time, id } = await res.json();
console.log("virtual key:", id, "— save the token, it's shown once.");

4. Use it like the upstream

const reply = await fetch("https://proxy.edgify.net/v1/chat/completions", {
  method: "POST",
  headers: {
    authorization: `Bearer ${token_one_time}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    model: "gpt-4o-mini",
    messages: [{ role: "user", content: "Say hi in 4 words." }],
  }),
});
console.log(await reply.json());

The proxy validates the key, decrypts your master credential at the edge, forwards to OpenAI, and records a usage event — all in < 1 ms of Edgify overhead.

Next