Skip to main content

A Python SDK for interacting with Frontegg AI Agents.

Project description

Frontegg AI Python SDK

The Frontegg AI Python SDK provides AI Agent developers with tools and utilities to easily empower AI agents within their applications. This SDK seamlessly integrates with the Frontegg platform, enabling advanced tool authentication, authorization, and identity management capabilities for AI Agents.

Installation

pip install frontegg-ai-sdk

Features

  • Secure integration with Frontegg authentication

  • Easy integration with Frontegg built-in and 3rd party application tools

  • User identity context for agent throught Frontegg's identity platform

  • Seamless integration with CrewAI agent tools

Quick Start

import asyncio
import os
from frontegg_ai_python_sdk import (
    Environment,
    FronteggAiClientConfig,
    FronteggAiClient
)

# Async usage
async def async_example():
    # Create client configuration
    config = FronteggAiClientConfig(
        environment=Environment.US,
        agent_id=os.environ.get("FRONTEGG_AGENT_ID"),
        client_id=os.environ.get("FRONTEGG_CLIENT_ID"),
        client_secret=os.environ.get("FRONTEGG_CLIENT_SECRET"),
    )

    # Create client
    client = FronteggAiClient(config)

    # Set Context manually
    tenant_id = os.getenv("FRONTEGG_TENANT_ID")
    user_id = os.getenv("FRONTEGG_USER_ID")
    client.set_context(tenant_id=tenant_id, user_id=user_id)

    # Or set the context using the user JWT
    user_jwt = "Bearer eyJ..."
    client.set_user_context_by_jwt(user_jwt)

    # List available tools
    tools = await client.list_tools()
    print(f"Available tools: {tools}")

    # Call a tool with arguments
    result = await client.call_tool(
        name="your_tool_name",
        arguments={"param1": "value1"},
    )
    print(f"Tool result: {result}")

if __name__ == "__main__":
    # Run async example
    asyncio.run(async_example())

CrewAI Integration

The SDK supports integration with CrewAI for tool usage:

import asyncio
from crewai import Agent, Crew, Task
from frontegg_ai_python_sdk import (
    Environment,
    FronteggAiClientConfig,
    FronteggAiClient
)

async def get_crewai_tools():
    # Configure Frontegg client
    config = FronteggAiClientConfig(
        environment=Environment.US,
        agent_id=os.environ.get("FRONTEGG_AGENT_ID"),
        client_id=os.environ.get("FRONTEGG_CLIENT_ID"),
        client_secret=os.environ.get("FRONTEGG_CLIENT_SECRET"),
    )

    # Create client
    client = FronteggAiClient(config)

    # Set Context manually
    tenant_id = os.getenv("FRONTEGG_TENANT_ID")
    user_id = os.getenv("FRONTEGG_USER_ID")
    client.set_context(tenant_id=tenant_id, user_id=user_id)

    # Or set the context using the user JWT
    user_jwt = "Bearer eyJ..."
    client.set_user_context_by_jwt(user_jwt)

    # Get tools as CrewAI tools
    tools = await client.list_tools_as_crewai_tools()
    return tools

# Get CrewAI tools
tools = asyncio.run(get_crewai_tools())

# Create an agent with Frontegg tools
agent = Agent(
    role="Research Assistant",
    goal="Find and analyze information",
    backstory="I am an AI research assistant with access to various tools.",
    tools=tools,
    verbose=True
)

# Create tasks for the agent
task = Task(
    description="Research topic X and provide insights",
    expected_output="A comprehensive report",
    agent=agent
)

# Create and run the crew
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()

Environment Configuration

The SDK supports multiple Frontegg environments:

from frontegg_ai_python_sdk import Environment

# Available environments
Environment.EU # European servers: 'eu.frontegg.com'
Environment.US # US servers: 'us.frontegg.com'
Environment.CA # Canadian servers: 'ca.frontegg.com'
Environment.AU # Australian servers: 'au.frontegg.com'
Environment.UK # UK servers: 'uk.frontegg.com'

Custom Logging

from frontegg_ai_python_sdk import setup_logger
import logging

# Set up a custom logger
logger = setup_logger(
    name="my_custom_logger",
    level=logging.DEBUG,
    format_string="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    file_handler="app.log"  # Also log to a file
)

# Use the custom logger with the client
client = FronteggAiClient(config, logger=logger)

Requirements

  • Python 3.8+

  • asyncio

  • httpx

  • anyio

  • nest_asyncio (for nested event loops)

  • pydantic

  • modelcontextprotocol

  • crewai (optional, for CrewAI integration)

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

frontegg_ai_sdk-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

frontegg_ai_sdk-0.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file frontegg_ai_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: frontegg_ai_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for frontegg_ai_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c4fca415d5407ed3befc0dd5ffb6a6c32c6d1662e5f278b386a6fedda7d9104c
MD5 5ce84efd00ab85747777318666ca7d79
BLAKE2b-256 73d270d8dd94be634655098be2d24a8401c1980a4f2a12ffb0eb591a5ffd9768

See more details on using hashes here.

File details

Details for the file frontegg_ai_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for frontegg_ai_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 880393e52817daa821653a4ba23b1ba1ba9ebcc3b9539c2d61f9c031bb4a52bd
MD5 99b2ad5536b9689ceb99c2df40371e7e
BLAKE2b-256 3e11777920fa693d37a0cab696f3b04e72ca46bb56a252e31df209aac09c14c9

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