🚀 Cloak is in Public Beta. Get unlimited access for free.

Documentation

Learn how to integrate Cloak's AI Financial Firewall into your agent workflow.

Quick Start

1. Create a Vault & Set Budget

Vaults are secure containers for your API keys. Create a vault and set a Daily Budget Limit (e.g., $10.00). This is your hard ceiling.

2. Add Provider Keys

Inside a vault, add your API keys for OpenAI, Anthropic, or OpenRouter. These keys are encrypted and never exposed to your applications.

3. Issue Cloak Keys

Generate a ck_live_... key for your agent. If the Vault's budget is exceeded, Cloak's Circuit Breaker will instantly block requests with a 402 Payment Required error.

API Reference

Cloak acts as a secure proxy for your AI providers. Point your client to the Cloak proxy endpoint.

POST/api/proxy

Forwards requests to the specified AI provider.

Headers

AuthorizationBearer <your_cloak_key>
X-Cloak-ProviderRequired. One of: openai, anthropic, openrouter
Content-Typeapplication/json

Example Request (OpenAI)

curl https://cloak.guna.dev/api/proxy \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ck_live_12345..." \
  -H "X-Cloak-Provider: openai" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Hello world"}
    ]
  }'

Integration Examples

OpenAI Node.js SDK

import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: "ck_live_12345...", // Your Cloak Key
  baseURL: "https://cloak.guna.dev/api/proxy",
  defaultHeaders: {
    "X-Cloak-Provider": "openai"
  }
});

const completion = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});

OpenAI with Fetch

const response = await fetch("https://cloak.guna.dev/api/proxy", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer ck_live_12345...",
    "X-Cloak-Provider": "openai"
  },
  body: JSON.stringify({
    model: "gpt-4o",
    messages: [{ role: "user", content: "Hello!" }]
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);

Anthropic SDK

import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic({
  apiKey: "ck_live_12345...", // Your Cloak Key
  baseURL: "https://cloak.guna.dev/api/proxy",
  defaultHeaders: {
    "X-Cloak-Provider": "anthropic"
  }
});

const message = await anthropic.messages.create({
  model: "claude-3-5-sonnet-20240620",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello!" }],
});

Anthropic with Fetch

const response = await fetch("https://cloak.guna.dev/api/proxy", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer ck_live_12345...",
    "X-Cloak-Provider": "anthropic"
  },
  body: JSON.stringify({
    model: "claude-3-5-sonnet-20240620",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello!" }]
  })
});

const data = await response.json();
console.log(data.content[0].text);

OpenRouter (OpenAI SDK)

import OpenAI from "openai";

const openrouter = new OpenAI({
  apiKey: "ck_live_12345...", // Your Cloak Key
  baseURL: "https://cloak.guna.dev/api/proxy",
  defaultHeaders: {
    "X-Cloak-Provider": "openrouter"
  }
});

const completion = await openrouter.chat.completions.create({
  model: "anthropic/claude-3-opus", // Use OpenRouter model ID
  messages: [{ role: "user", content: "Hello!" }],
});