Skip to main content

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.

Metadata

Release files for frontegg-ai-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for frontegg-ai-sdk 1.0.0
File Size Uploaded Provenance Actions
frontegg_ai_sdk-1.0.0.tar.gz 12.7 kB Without provenance Details for frontegg_ai_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for frontegg-ai-sdk 1.0.0
File Interpreter ABI Platform Actions
frontegg_ai_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for frontegg_ai_sdk-1.0.0-py3-none-any.whl

Total release size: 26.0 kB

Release files / frontegg_ai_sdk-1.0.0.tar.gz

Download URL frontegg_ai_sdk-1.0.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
71100795465ec28b8230489e3df5b41f09729d70cc96794f523ef37c8401a50e
BLAKE2b-256 checksum
How to use checksums
d40adef48475c11063db7f82e44c37c8b323f6e6d0b38d811d19d2e808074708
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Release files / frontegg_ai_sdk-1.0.0-py3-none-any.whl

Download URL frontegg_ai_sdk-1.0.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6a8e6be50eecb4361cf03635ea19aef901d4f0247c4e1e913761e504a909743
BLAKE2b-256 checksum
How to use checksums
08d15c207d5e3338b7eb67d53273f641f2c972a5d60237666b181ca4e89e7545
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Security for frontegg-ai-sdk 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page