Python SDK for building and instrumenting AI agents with FastAPI integration
Project description
Gradient Agent
A Python SDK for building and instrumenting AI agents with FastAPI integration and comprehensive runtime tracking.
Features
- @entrypoint decorator - Easy FastAPI server creation from agent functions
- Runtime instrumentation - Complete observability for LangGraph-based agents
- Request tracking - Monitor agent performance and behavior
- Context management - Maintain state across agent executions
Quick Start
from gradient_sdk import entrypoint
@entrypoint
def my_agent(prompt: str, max_tokens: int = 100) -> str:
"""Simple echo agent"""
return f"Echo: {prompt} [max_tokens={max_tokens}]"
# The decorator automatically creates a FastAPI server
# Access at http://localhost:8080 when running
Installation
pip install gradient-agent
Usage
Basic Agent
from gradient_agent import entrypoint
@entrypoint
def simple_agent(prompt: str) -> str:
return f"Response to: {prompt}"
LangGraph Integration
from gradient_agent import entrypoint
from langgraph.graph import StateGraph
from gradient_agent.runtime import get_runtime_manager
@entrypoint
def langgraph_agent(prompt: str) -> str:
# Your LangGraph agent code here
# Runtime tracking is automatically enabled
pass
Manual Server Control
from gradient_agent import get_app
import uvicorn
# Import your agent modules first
import my_agent
# Get the FastAPI app
app = get_app()
# Run with custom configuration
uvicorn.run(app, host="0.0.0.0", port=8080)
API Endpoints
When you use the @entrypoint decorator, your agent automatically gets:
POST /completions- Main agent endpointGET /health- Health checkGET /- Basic info
Runtime Tracking
The SDK includes comprehensive runtime tracking for LangGraph-based agents:
- Node execution timing
- Request context management
- Performance metrics
- Error tracking
Development
This SDK is part of the larger Gradient ecosystem for AI agent development and deployment.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gradient_agent-0.1.0.tar.gz.
File metadata
- Download URL: gradient_agent-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c950ef94cecc5116eae6af743bb633be19afce3bad720811fa9fe80e1dfb0b0d
|
|
| MD5 |
444c4096253904c31da82b4b2bdd53b3
|
|
| BLAKE2b-256 |
2a6eb8ef3bf88104c463c6159e05a43fae67d06376d9279690045a678f36e419
|
File details
Details for the file gradient_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gradient_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6049931fd95830855f136ccd07c28763d8cbb73176e9670b802c7fc5dbee4dd7
|
|
| MD5 |
5b1179e5248f5fcb6225e55b0d1ff059
|
|
| BLAKE2b-256 |
7e06206f1c591411d8fb30e0293a10d55452f1623cea9b19017a3d3bcb7a8afa
|