Skip to main content

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 endpoint
  • GET /health - Health check
  • GET / - 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


Download files

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

Source Distribution

gradient_agent-0.1.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

gradient_agent-0.1.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gradient_agent-0.1.1.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

Hashes for gradient_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e5483e809a816dd5e9822ad209e593dff9c2e3b58e61a648140dc30fb67e304f
MD5 d514124681227324865fbf78cec56477
BLAKE2b-256 bb7ddf1e2c85074f86c50818619eecfbce506adfb15f57c960f593a7e804b278

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gradient_agent-0.1.1-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

Hashes for gradient_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b209f541726624fc3539d8cbd6ce532f72b27d4c165f56a868e62f5a5192aba0
MD5 fb425a5bb1202750bc590e9d747ad2fa
BLAKE2b-256 dadf4974e8c489f0533f7bc5881ddd6480ad0c9a7b49bb3d39a0065d13b87796

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