SDK & CLI
Official SDKs, CLI, and sidecar for integrating AI agent security into your applications.
Official SDKs
Choose the SDK for your language. All SDKs provide the same core features: credential management, budget controls, prompt injection detection, and usage logging.
TypeScript / Node.js
For web apps, serverless functions, and Node.js backends. Includes OpenAI and LangChain integrations.
AvailablePython
For data pipelines, ML workflows, and Python backends. Async support included.
AvailableGo
For microservices, cloud-native apps, and high-performance systems.
AvailableTypeScript SDK
npm install @veraid/sdk # or yarn add @veraid/sdk
import { VeraIDClient } from '@veraid/sdk';
const client = new VeraIDClient({
apiKey: process.env.VERAID_API_KEY,
agentId: process.env.VERAID_AGENT_ID,
});
// Get a credential
const apiKey = await client.getCredential('openai-api-key');
// Check budget before making LLM calls
const canProceed = await client.checkBudget(0.05);
if (!canProceed) throw new Error('Budget exceeded');
// Check for prompt injection
const result = await client.checkInjection(userInput);
if (result.isInjection) {
console.error('Injection detected:', result.summary);
return;
}
// Record usage after LLM call
await client.recordUsage({
provider: 'openai',
model: 'gpt-4',
inputTokens: 500,
outputTokens: 200,
cost: 0.045,
latencyMs: 1200,
success: true,
}); OpenAI Integration
import OpenAI from 'openai';
import { VeraIDClient } from '@veraid/sdk';
import { wrapOpenAI } from '@veraid/sdk/openai';
const client = new VeraIDClient({
apiKey: process.env.VERAID_API_KEY,
agentId: process.env.VERAID_AGENT_ID,
});
// Wrap OpenAI - all calls monitored automatically
const openai = wrapOpenAI(new OpenAI(), client);
// Use as normal - budget, injection, logging handled
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: userInput }],
}); Python SDK
pip install veraid # With optional integrations pip install veraid[openai] pip install veraid[langchain] pip install veraid[all]
import os
from veraid import VeraIDClient
client = VeraIDClient(
api_key=os.environ["VERAID_API_KEY"],
agent_id=os.environ["VERAID_AGENT_ID"],
)
# Get a credential
api_key = await client.get_credential("openai-api-key")
# Check budget
can_proceed = await client.check_budget(0.05)
if not can_proceed:
raise Exception("Budget exceeded")
# Check for prompt injection
result = await client.check_injection(user_input)
if result.is_injection:
print(f"Injection detected: {result.summary}")
return
# Record usage
await client.record_usage(
provider="openai",
model="gpt-4",
input_tokens=500,
output_tokens=200,
cost=0.045,
latency_ms=1200,
success=True,
) OpenAI Integration
from openai import OpenAI
from veraid import VeraIDClient
from veraid.integrations.openai import wrap_openai
client = VeraIDClient(
api_key=os.environ["VERAID_API_KEY"],
agent_id=os.environ["VERAID_AGENT_ID"],
)
# Wrap OpenAI client
openai = wrap_openai(OpenAI(), client)
# All calls now monitored
response = openai.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": user_input}],
) Go SDK
go get github.com/BraineeTech/veraid/packages/sdk-go
package main
import (
"context"
"log"
veraid "github.com/BraineeTech/veraid/packages/sdk-go"
)
func main() {
// Create client from environment variables
client, err := veraid.NewClientFromEnv()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// Get a credential
apiKey, err := client.GetCredential(ctx, "openai-api-key")
if err != nil {
log.Fatal(err)
}
// Check budget
canProceed, _ := client.CheckBudget(ctx, 0.05)
if !canProceed {
log.Fatal("Budget exceeded")
}
// Check for prompt injection
result, _ := client.CheckInjection(ctx, userInput)
if result.IsInjection {
log.Printf("Injection detected: %s", result.Summary)
return
}
// Record usage
client.RecordUsage(ctx, veraid.UsageLog{
Provider: "openai",
Model: "gpt-4",
InputTokens: 500,
OutputTokens: 200,
Cost: 0.045,
LatencyMs: 1200,
Success: true,
})
} Environment Variables
| Variable | Required | Description |
|---|---|---|
VERAID_API_KEY | Yes | Your VeraID API key |
VERAID_AGENT_ID | Yes | The agent ID to use |
VERAID_BASE_URL | No | API base URL (default: https://api.veraid.io) |
VERAID_DEBUG | No | Enable debug logging ("true") |
SDK Methods
| Method | Description |
|---|---|
getCredential(name) | Retrieve a credential value from the vault |
listCredentials() | List all credentials available to the agent |
getBudgetStatus() | Get current budget limits and usage |
checkBudget(cost) | Check if estimated cost is within budget |
recordUsage(usage) | Log LLM usage for monitoring and billing |
checkInjection(prompt) | Check a prompt for injection attacks |
guardPrompt(prompt) | Check prompt and throw if injection detected |
getStats(period) | Get usage statistics (day/week/month) |
Sidecar Container
For applications that can't integrate the SDK directly, use the VeraID Sidecar. It runs as a container alongside your app, fetches credentials, and writes them to a shared volume.
services:
app:
image: your-app:latest
volumes:
- secrets:/secrets:ro
depends_on:
veraid-sidecar:
condition: service_healthy
veraid-sidecar:
image: ghcr.io/braineetech/veraid-sidecar:latest
environment:
VERAID_API_KEY: ${VERAID_API_KEY}
VERAID_AGENT_ID: ${VERAID_AGENT_ID}
VERAID_CREDENTIALS: "db-password,api-key,openai-key"
volumes:
- secrets:/secrets
volumes:
secrets:
The sidecar auto-refreshes credentials before they expire. Your app just reads from /secrets/.
CLI Tool
Manage identities, credentials, and budgets from your terminal.
npm install -g veraid-cli
# Configure veraid config set-api-key YOUR_API_KEY # List agents veraid agents list # Get credential veraid credentials get db-password # Check budget veraid budget status --agent agent_abc123 # Test prompt for injection veraid injection check "Ignore previous instructions..." # View analytics veraid analytics --period week
Check out the API Reference for detailed endpoint documentation, or reach out to support@veraid.io for assistance.