Back to Home

Documentation

Complete guide to integrating SecureGate with your AI agents using standard SDKs.


Core Concepts

Connection ID

A public identifier (e.g., openai_123abc) that tells SecureGate which encrypted provider key to use. It's safe to expose in your code.

Security Key

A specialized key (sk_...) generated in your dashboard. This authenticates your agent to SecureGate. It is scoped, revocable, and auditable.

Prerequisites

1

Create a Connection

Go to your dashboard and add a new connection (e.g., for OpenAI). This securely stores your actual API key.

2

Generate a Security Key

In the connection details, click "Generate Key". Copy safely—it's shown only once.

3

Get Proxy URL

Your proxy URL is https://<YOUR_PROJECT_REF>.supabase.co/functions/v1/proxy/v1

PythonOpenAI Python SDK

Use the standard openai library. You don't need to install anything new. Just point the base_url to SecureGate.

main.py
from openai import OpenAI
import os

# Configuration
SECURE_GATE_URL = "https://<YOUR_PROJECT_REF>.supabase.co/functions/v1/proxy/v1"
CONNECTION_ID = "openai_x8z92a" # From Dashboard
SECURITY_KEY = "sk_..."         # Generated in Dashboard

client = OpenAI(
    api_key=SECURITY_KEY,
    base_url=SECURE_GATE_URL,
    # We pass the connection ID as a custom header so SecureGate knows which key to decrypt
    default_headers={
        "x-connection-id": CONNECTION_ID
    }
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Hello, secure world!"}
    ]
)

print(response.choices[0].message.content)

Node.jsOpenAI Node.js SDK

Compatible with the official openai npm package.

index.js
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.SECURITY_KEY, // sk_...
  baseURL: 'https://<YOUR_PROJECT_REF>.supabase.co/functions/v1/proxy/v1',
  defaultHeaders: {
    'x-connection-id': process.env.CONNECTION_ID // openai_...
  }
});

async function main() {
  const chatCompletion = await client.chat.completions.create({
    messages: [{ role: 'user', content: 'Hello, secure world!' }],
    model: 'gpt-4o',
  });

  console.log(chatCompletion.choices[0].message.content);
}

main();