GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cycles-client-python/examples at main · runcycles/cycles-client-python

Expand file tree

/

examples

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

examples

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
README.md
README.md
 
 
anthropic_integration.py
anthropic_integration.py
 
 
async_usage.py
async_usage.py
 
 
basic_usage.py
basic_usage.py
 
 
decorator_usage.py
decorator_usage.py
 
 
fastapi_integration.py
fastapi_integration.py
 
 
langchain_integration.py
langchain_integration.py
 
 
openai_integration.py
openai_integration.py
 
 
streaming_usage.py
streaming_usage.py
 
 

README.md

Outline

Cycles Python Client Examples

Runnable examples demonstrating how to integrate the runcycles client into real-world Python applications.

Prerequisites

  1. A running Cycles server (see Deploy the Full Stack)
  2. Set environment variables:
export CYCLES_BASE_URL="http://localhost:7878"
export CYCLES_API_KEY="your-api-key"   # create via Admin Server — see link above
export CYCLES_TENANT="acme"
  1. Install the client:
pip install runcycles

Examples

File Description Extra Dependencies
basic_usage.py Programmatic reserve → commit lifecycle —
decorator_usage.py @cycles decorator with estimates, caps, and metrics —
async_usage.py Async client and async decorator —
openai_integration.py Guard OpenAI chat completions with budget checks openai
anthropic_integration.py Guard Anthropic messages with per-tool budget tracking anthropic
streaming_usage.py stream_reservation() context manager with auto-commit openai
fastapi_integration.py FastAPI middleware, dependency injection, per-tenant budgets fastapi, uvicorn
langchain_integration.py Concurrent-safe LangChain callback using heartbeat and durable settlement langchain, langchain-openai

Running

# Basic examples (only need a Cycles server)
python examples/basic_usage.py
python examples/decorator_usage.py
python examples/async_usage.py

# Integration examples (need additional API keys)
export OPENAI_API_KEY="sk-..."
python examples/openai_integration.py
python examples/streaming_usage.py

export ANTHROPIC_API_KEY="sk-ant-..."
python examples/anthropic_integration.py

# FastAPI (starts a server on port 8000)
pip install fastapi uvicorn
python examples/fastapi_integration.py

# LangChain
pip install langchain langchain-openai
python examples/langchain_integration.py
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.