@ethicalzen/sdk
Version:
Official EthicalZen SDK for Node.js - AI safety guardrails made simple
75 lines • 2.24 kB
TypeScript
import { AxiosInstance } from 'axios';
export interface ProxyConfig {
gatewayUrl: string;
contractId: string;
tenantId: string;
certificateId?: string;
}
/**
* EthicalZen Proxy Client
*
* Wraps any HTTP client to route requests through ACVPS Gateway.
* Gateway validates responses in real-time using contract envelope.
*
* @example
* ```typescript
* import { createProxyClient } from '@ethicalzen/sdk';
*
* const client = createProxyClient({
* gatewayUrl: 'https://gateway.ethicalzen.ai:8443',
* contractId: 'my-service/healthcare/us/v1.0',
* tenantId: 'tenant-123'
* });
*
* // Make any HTTP request - gateway validates automatically
* const response = await client.post('https://api.openai.com/v1/chat/completions', {
* model: 'gpt-4',
* messages: [{ role: 'user', content: 'Hello' }]
* });
*
* // If response contains violations, gateway returns 409 error
* ```
*/
export declare function createProxyClient(config: ProxyConfig): AxiosInstance;
/**
* Wrap an existing axios instance to route through ACVPS Gateway
*
* @example
* ```typescript
* import axios from 'axios';
* import { wrapWithProxy } from '@ethicalzen/sdk';
*
* const myClient = axios.create({ timeout: 30000 });
*
* const protectedClient = wrapWithProxy(myClient, {
* gatewayUrl: 'https://gateway.ethicalzen.ai:8443',
* contractId: 'my-service/healthcare/us/v1.0',
* tenantId: 'tenant-123'
* });
* ```
*/
export declare function wrapWithProxy(client: AxiosInstance, config: ProxyConfig): AxiosInstance;
/**
* Simple function to add contract headers to any request config
* For use with libraries that don't support axios
*
* @example
* ```typescript
* import { addContractHeaders } from '@ethicalzen/sdk';
*
* const headers = addContractHeaders({
* contractId: 'my-service/healthcare/us/v1.0',
* tenantId: 'tenant-123'
* });
*
* // Use with fetch, node-fetch, or any HTTP client
* fetch('https://api.openai.com/v1/chat/completions', {
* headers: {
* ...headers,
* 'Authorization': 'Bearer sk-...'
* }
* });
* ```
*/
export declare function addContractHeaders(config: Omit<ProxyConfig, 'gatewayUrl'>): Record<string, string>;
//# sourceMappingURL=proxy.d.ts.map