Skip to main content

Streaming-first LLM runtime for real-time systems

Project description

owly-ai

Streaming-first LLM runtime and lightweight agent loop for real-time systems.

PyPI version Python License

New in this release

  • Vertex AI Gemini provider (provider="vertex")
  • Anthropic Claude provider (provider="claude")
  • Unified timeout controls (request_timeout, first_token_timeout)
  • Improved cancellation safety and stream cleanup
  • Provider-level observability (provider, model, latency, request_id)

Installation

pip install owly-ai

Use in other projects:

# pyproject.toml
dependencies = ["owly-ai"]
# requirements.txt
owly-ai

Import path:

from owly_ai import LLM

Supported providers

  • OpenAI: provider="openai"
  • Gemini (Google AI Studio): provider="gemini"
  • Vertex AI Gemini: provider="vertex"
  • Anthropic Claude: provider="claude"

Credentials

export OPENAI_API_KEY="sk-..."
export GEMINI_API_KEY="AIza..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GOOGLE_CLOUD_PROJECT="my-project"      # Vertex
export GOOGLE_CLOUD_LOCATION="us-central1"    # Vertex (optional)

Quickstart

import asyncio

from owly_ai import LLM
from owly_ai.core.types import LLMRequest, Message


async def main() -> None:
    llm = LLM(provider="openai", model="gpt-4o-mini")
    request = LLMRequest(
        messages=[Message(role="user", content="Explain asyncio in one paragraph.")],
        temperature=0.2,
        request_id="req-123",
    )

    async for chunk in llm.stream(request):
        if hasattr(chunk, "text") and chunk.text:
            print(chunk.text, end="", flush=True)

    print()


asyncio.run(main())

Agent quickstart

import asyncio

from owly_ai import Agent, LLM, Tool


def get_weather(location: str) -> str:
    data = {"tokyo": "Clear, 22C", "london": "Rainy, 12C"}
    return data.get(location.lower(), "Sunny, 20C")


async def main() -> None:
    llm = LLM(provider="openai", model="gpt-4o-mini")
    agent = Agent(
        llm=llm,
        tools=[Tool.from_function(get_weather)],
        system_prompt="You are a concise weather assistant.",
    )

    async for chunk in agent.stream("What's the weather in Tokyo?"):
        if hasattr(chunk, "text") and chunk.text:
            print(chunk.text, end="", flush=True)

    print()


asyncio.run(main())

Runtime configuration

from owly_ai import LLM
from owly_ai.infra.config import OwlyConfig

cfg = OwlyConfig(
    request_timeout=30.0,
    first_token_timeout=5.0,
    max_concurrency=256,
    queue_maxsize=256,
)
llm = LLM(provider="claude", model="claude-3-5-sonnet-latest", config=cfg)

Examples

See examples/README.md for runnable commands:

  • examples/openai_stream.py
  • examples/gemini_stream.py
  • examples/vertex_stream.py
  • examples/claude_stream.py
  • examples/cancel_stream.py
  • examples/agent_weather.py

Architecture

owly_ai/
 ├── core/        # contracts + exceptions + core types
 ├── providers/   # provider adapters
 ├── runtime/     # cancellation + normalizer + pipeline
 ├── infra/       # config + logging
 ├── utils/       # async helpers
 ├── llm.py       # public runtime interface
 ├── agent.py     # optional agent loop
 ├── tools.py     # tool definition helpers
 └── memory.py    # memory protocol + in-memory impl

Pipeline:

provider -> cancellable -> normalized -> user

Contributing

  • Keep provider-specific logic inside owly_ai/providers/*
  • Preserve streaming and cancellation guarantees
  • Add tests for new behaviors in tests/

License

Apache 2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

owly_ai-0.1.1.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

owly_ai-0.1.1-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file owly_ai-0.1.1.tar.gz.

File metadata

  • Download URL: owly_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for owly_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 06e06ca26da9f9c14bd37ff94ff272f2398f604b1cd78150470b6965ab1a0197
MD5 38641a719d28513f9613f8ac79159667
BLAKE2b-256 7c34b1f926916da1735698666ac53eb4a0a8169d64d0c93198a2362548de6318

See more details on using hashes here.

File details

Details for the file owly_ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: owly_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for owly_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32b6d0978eb1b5e6706c96bd15156862e5acb08e6343ed422d8676ceb8f48808
MD5 73c9d54b11bb90671fa7615985450534
BLAKE2b-256 806297867b90ecbbdbb79ee281edf079ab78da259cb74994e0351144491638a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page