Skip to main content

Raven SDK

Async Kafka and HTTP producer SDK for AI logs with support for both streaming and batch processing.

Features

  • Kafka Producer: Async Kafka producer for streaming AI logs
  • HTTP Producer: Simple HTTP producer for batch AI log submissions
  • Pydantic Models: Type-safe AI log models with automatic JSON serialization
  • UTC Timestamps: Automatic UTC timestamp formatting with ISO-8601 standard

Installation

pip install raven-sdk

Quick Start

Kafka Producer

import asyncio
from datetime import datetime
from raven import AiLog, AiLogKafkaProducer

async def main():
    # Create producer
    producer = AiLogKafkaProducer("localhost:9092", topic="ai-logs")
    
    # Start producer
    await producer.start()
    
    try:
        # Create AI log
        log = AiLog(
            modelId="gpt-4",
            confidenceScore=0.95,
            responseTimeMs=150,
            timestamp=datetime.utcnow(),
            numericFeatures={"temperature": 0.7},
            categoricalFeatures={"type": "completion"}
        )
        
        # Send logs
        await producer.produce_ai_logs([log])
        
    finally:
        await producer.stop()

asyncio.run(main())

HTTP Producer

import asyncio
from datetime import datetime
from raven import AiLog, AiLogHttpProducer

async def main():
    # Create producer
    producer = AiLogHttpProducer("https://api.example.com/logs")
    
    # Create AI log
    log = AiLog(
        modelId="gpt-4",
        confidenceScore=0.95,
        responseTimeMs=150,
        timestamp=datetime.utcnow(),
        numericFeatures={"temperature": 0.7},
        categoricalFeatures={"type": "completion"}
    )
    
    # Send logs (no start/stop needed)
    await producer.produce_ai_logs([log])

asyncio.run(main())

API Reference

AiLog

Pydantic model representing an AI log entry.

Fields:

  • modelId: str - Identifier for the AI model
  • confidenceScore: float - Confidence score of the prediction
  • responseTimeMs: int - Response time in milliseconds
  • timestamp: datetime - UTC timestamp of the log
  • numericFeatures: Dict[str, float] - Numeric features
  • categoricalFeatures: Dict[str, str] - Categorical features

AiLogKafkaProducer

Async Kafka producer for AI logs.

Methods:

  • __init__(kafka_bootstrap_servers: str, topic: str = "ai-logs")
  • async start() - Start the producer
  • async stop() - Stop the producer
  • async produce_ai_logs(logs: List[AiLog]) - Send batch of logs
  • async produce_stream_logs(logs: AsyncIterable[AiLog]) - Send streaming logs

AiLogHttpProducer

Simple HTTP producer for AI logs.

Methods:

  • __init__(endpoint_url: str, timeout: int = 30)
  • async produce_ai_logs(logs: List[AiLog]) - Send batch of logs via POST

Requirements

  • Python 3.8+
  • aiokafka>=0.8
  • pydantic>=2.0
  • aiohttp>=3.8

License

MIT License

Metadata

Release files for raven-sdk 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raven-sdk 0.1.3
File Size Uploaded Provenance Actions
raven_sdk-0.1.3.tar.gz 2.9 kB Without provenance Details for raven_sdk-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for raven-sdk 0.1.3
File Interpreter ABI Platform Actions
raven_sdk-0.1.3-py3-none-any.whl Python 3 none any Details for raven_sdk-0.1.3-py3-none-any.whl

Total release size: 6.0 kB

Release files / raven_sdk-0.1.3.tar.gz

Download URL raven_sdk-0.1.3.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7109d0ec13e4559cc2e576b691348cb828178edfa793b231eb92db1e7fb68ffb
BLAKE2b-256 checksum
How to use checksums
b33400b1989f992cd7a926691483118b7141225d16c8162a8876616f66a04643
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release files / raven_sdk-0.1.3-py3-none-any.whl

Download URL raven_sdk-0.1.3-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42c68f97ed45da7392819c9eee828cede589d54a00dc029f86566219429e721a
BLAKE2b-256 checksum
How to use checksums
86edbaae31cdd49b18a33c27114de33e5f2a2973691327ab168651f133a3d928
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Security for raven-sdk 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page