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.2.tar.gz (9.7 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.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gradient_agent-0.1.2.tar.gz
  • Upload date:
  • Size: 9.7 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.2.tar.gz
Algorithm Hash digest
SHA256 f654383b1b6fe9d0d4a82afa54cd45215b0580e2294ed9b78f05e0ce4c03a84e
MD5 3b38e4918923de643fd4ba743aa1f980
BLAKE2b-256 2f9a07e1aa01d4f6f0a6ab1e256910a27afde356c8b004734f9f344d4acf6b0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gradient_agent-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 53adf09145490fe5238f1623dc2f07bbab50b000946b1f137e40d56fcc3f4dc4
MD5 30809070e1a3296c97691ea03c50162a
BLAKE2b-256 23e5a1201f96cfe09a85d45a88c329aa06b98d1a6918ca4a60b3226fe8e34b2b

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