Getting Started

Prerequisites

  • Python 3.8+ or Node.js 16+

  • Solana wallet (for on-chain verification)

  • OpenAI or Claude API key

Installation

Python SDK

pip install civitas-sdk

JavaScript SDK

npm install civitas-sdk

Quick Start Example

Python

from civitas import ProofAgent

# Initialize agent with your API key
agent = ProofAgent(
    api_key="your-api-key",
    model="gpt-4"
)

# Make a verified inference
response = agent.infer(
    message="What is the weather today?",
    verify=True
)

print(response.message)
print(response.proof)

# Verify proof on-chain
is_valid = agent.verify_proof(response.proof)
print(f"Proof valid: {is_valid}")

JavaScript

const { ProofAgent } = require('civitas-sdk');

// Initialize agent
const agent = new ProofAgent({
  apiKey: 'your-api-key',
  model: 'gpt-4'
});

// Make verified inference
const response = await agent.infer({
  message: 'What is the weather today?',
  verify: true
});

console.log(response.message);
console.log(response.proof);

// Verify proof
const isValid = await agent.verifyProof(response.proof);
console.log(`Proof valid: ${isValid}`);

Verification Instructions

To verify the code running inside the TEE, follow the instructions provided in the verify documentation.


SDK Reference

Agent Initialization

agent = ProofAgent(
    api_key: str,           # Your API key
    model: str,             # LLM model (e.g., "gpt-4", "claude-3")
    network: str = "mainnet" # Solana network
)

Making Inferences

response = agent.infer(
    message: str,           # User prompt
    verify: bool = True,    # Generate cryptographic proof
    temperature: float = 0.7,
    max_tokens: int = 1000
)

Response Object

{
    "message": str,         # LLM response
    "proof": {
        "hash": str,        # Input/output hash
        "signature": str,   # Cryptographic signature
        "attestation": str, # TEE attestation
        "timestamp": int,   # Unix timestamp
        "solana_tx": str    # Transaction hash
    }
}

Verification Methods

# Verify a single proof
is_valid = agent.verify_proof(proof: dict) -> bool

# Retrieve proof history
proofs = agent.get_proof_log(limit: int = 10) -> list

# Verify on-chain attestation
attestation = agent.verify_on_chain(tx_hash: str) -> dict

Framework Integration

Civitas works with existing AI agent frameworks:

ELIZA Integration

from civitas import ProofAgent
from eliza import ElizaAgent

agent = ElizaAgent()
proof_agent = ProofAgent(api_key="...")

# Wrap ELIZA responses with proofs
def verified_response(message):
    response = agent.respond(message)
    return proof_agent.create_proof(response)

Custom Integration

# Add verification to any agent
class MyAgent:
    def __init__(self):
        self.proof_agent = ProofAgent(...)
    
    def respond(self, message):
        # Your agent logic
        result = self.generate_response(message)
        
        # Add cryptographic proof
        return self.proof_agent.create_proof(result)

Last updated