Skip to main content

A Minimal agent runtime built on OpenAI Responses API

Project description

LiteRun 🚀

PyPI - Version PyPI - Python Version PyPI - License Documentation

A lightweight, flexible Python framework for building custom OpenAI agents (Responses API) with tool support and structured prompt management.

Features

  • Custom Agent Execution: Control the loop with synchronous and streaming support.
  • Tool Support: Easy registration with Pydantic-powered validation.
  • Type Safety: Built for modern Python 3.10+ environments.
  • Async & Sync: Standard synchronous methods (invoke/stream) and full asyncio support (ainvoke/astream).
  • Prompt Templates: Structured message management.
  • Event-Driven: Granular control via a rich event system.

For detailed documentation on Architecture, Streaming, and Advanced Configuration, see DOCS.md.

Requirements

  • Python 3.10+

Note: Core dependencies like openai and pydantic are automatically installed when you install literun.

Installation

You can install literun directly from PyPI:

pip install literun

Quick Start

Basic Agent

Here is a simple example of how to create an agent with a custom tool.

import os
from literun import Agent, ChatOpenAI, Tool, ArgsSchema

# 1. Define a tool function
def get_weather(location: str, unit: str = "celsius") -> str:
    return f"The weather in {location} is 25 degrees {unit}."

# 2. Wrap it with Tool schema
weather_tool = Tool(
    func=get_weather,
    name="get_weather",
    description="Get the weather for a location",
    args_schema=[
        ArgsSchema(
            name="location",
            type=str,
            description="The city and state, e.g. San Francisco, CA",
        ),
        ArgsSchema(
            name="unit",
            type=str,
            description="The unit of temperature",
            enum=["celsius", "fahrenheit"],
        ),
    ],
)

# 3. Initialize Agent
agent = Agent(
    llm=ChatOpenAI(model="gpt-4.1-mini", temperature=0.7),
    system_prompt="You are a helpful assistant.",
    tools=[weather_tool],
)

# 4. Run the Agent
result = agent.invoke(user_input="What is the weather in Tokyo?")
print(f"Final Answer: {result.final_output}")

Advanced Usage

LiteRun supports Streaming, Runtime Context Injection (for secrets), and Direct LLM Usage.

👉 Check out the Documentation and Examples for more details.

Project Structure

literun/
├── src/
│   └── literun/          # Main package source
│       ├── agent.py      # Agent orchestrator
│       ├── llm.py        # ChatOpenAI wrapper
│       ├── tool.py       # Tool & Schema definitions
│       └── ...
├── tests/                # Unit tests (agent, llm, tools, prompts)
├── examples/             # Runnable examples
├── DOCS.md               # Detailed documentation
├── LICENSE               # MIT License
├── README.md             # This file
└── pyproject.toml        # Project configuration & dependencies

Contributing

We welcome contributions! Please follow these steps to set up your development environment:

  1. Fork the repository and clone it locally:

    git clone https://github.com/kaustubh-tr/literun.git
    cd literun
    
  2. Install in editable mode with development dependencies:

    pip install -e .[dev]
    
  3. Create a feature branch and make your changes.

  4. Test your changes (see below).

  5. Submit a pull request.

Testing

This project uses pytest as the primary test runner, but supports unittest as well.

# Run all tests
pytest

or using unittest:

python -m unittest discover tests

Note: Some integration tests require the OPENAI_API_KEY environment variable. They are automatically skipped if it is missing.

License

Copyright (c) 2026 Kaustubh Trivedi.

Distributed under the terms of the MIT license, LiteRun is free and open source software.

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

literun-0.2.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

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

literun-0.2.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file literun-0.2.0.tar.gz.

File metadata

  • Download URL: literun-0.2.0.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for literun-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0e5b016af8ba3dca58317e65d7a28bbd78c0a8118b0c3658c31a1439cee62a0a
MD5 0b712d849043080620f2397aeeaca45e
BLAKE2b-256 836a2235ce52bc5fbc39fa646973aba87b6d0c10e84615f3a9eb5e1b1da6b121

See more details on using hashes here.

File details

Details for the file literun-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: literun-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for literun-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a5f95a5493ae819e923aac1a3fd5250a1e30a74a375dcfeb138e8b8ac644ff0
MD5 d9447f2b3a75fbfc93026383639ef403
BLAKE2b-256 025d179224cd9172683852a82a1fd4c7c3503e313dc6c021062204fa390333db

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