{"id":34726815,"url":"https://github.com/getaxonflow/axonflow-sdk-python","last_synced_at":"2026-04-30T01:03:16.508Z","repository":{"id":327592606,"uuid":"1109988412","full_name":"getaxonflow/axonflow-sdk-python","owner":"getaxonflow","description":"AxonFlow Python SDK - Enterprise AI governance in 3 lines of code","archived":false,"fork":false,"pushed_at":"2026-03-07T19:47:30.000Z","size":316,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-08T00:28:48.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getaxonflow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-04T15:01:25.000Z","updated_at":"2026-03-07T19:21:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/getaxonflow/axonflow-sdk-python","commit_stats":null,"previous_names":["getaxonflow/axonflow-sdk-python"],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/getaxonflow/axonflow-sdk-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getaxonflow%2Faxonflow-sdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getaxonflow%2Faxonflow-sdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getaxonflow%2Faxonflow-sdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getaxonflow%2Faxonflow-sdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getaxonflow","download_url":"https://codeload.github.com/getaxonflow/axonflow-sdk-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getaxonflow%2Faxonflow-sdk-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30286125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-25T02:30:37.327Z","updated_at":"2026-04-30T01:03:16.500Z","avatar_url":"https://github.com/getaxonflow.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AxonFlow Python SDK\n\nEnterprise AI Governance in 3 Lines of Code.\n\n[![PyPI version](https://badge.fury.io/py/axonflow.svg)](https://badge.fury.io/py/axonflow)\n[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Type hints](https://img.shields.io/badge/type%20hints-mypy-brightgreen.svg)](http://mypy-lang.org/)\n\n\u003e **Upgrade strongly recommended.** AxonFlow ships substantial monthly security and quality hardening; staying on the latest major is the security-supported release line. [Latest release](https://github.com/getaxonflow/axonflow-sdk-python/releases/latest) · [Security advisories](https://github.com/getaxonflow/axonflow-sdk-python/security/advisories)\n\n\u003e **Evaluating AxonFlow in production?** We're opening limited Design Partner slots.\n\u003e\n\u003e Free 30-minute architecture and incident-readiness review, priority issue triage, roadmap input, and early feature access.\n\u003e\n\u003e [Apply here](https://getaxonflow.com/design-partner?utm_source=readme_sdk_python) or email [design-partners@getaxonflow.com](mailto:design-partners@getaxonflow.com).\n\u003e\n\u003e No commitment required. We reply within 48 hours.\n\n\u003e **Questions or feedback?**\n\u003e\n\u003e Comment in [GitHub Discussions](https://github.com/getaxonflow/axonflow/discussions/239) or email [hello@getaxonflow.com](mailto:hello@getaxonflow.com) for private feedback.\n\n## How This SDK Fits with AxonFlow\n\nThis SDK is a client library for interacting with a running AxonFlow control plane. It is used from application or agent code to send execution context, policies, and requests at runtime.\n\nA deployed AxonFlow platform (self-hosted or cloud) is required for end-to-end AI governance. SDKs alone are not sufficient—the platform and SDKs are designed to be used together.\n\n### See AxonFlow in Action\n\nThree short videos covering different angles of the platform:\n\n- **[Community Quickstart Demo (Code + Terminal, 2.5 min)](https://youtu.be/BSqU1z0xxCo)** — governed calls, PII block, Gateway Mode with LangChain/CrewAI, and MAP from YAML\n- **[Runtime Control Demo (Portal + Workflow, 3 min)](https://youtu.be/6UatGpn7KwE)** — approvals, retry safety, execution state, and the audit viewer\n- **[Architecture Deep Dive (12 min)](https://youtu.be/Q2CZ1qnquhg)** — how the control plane works, policy enforcement flow, and multi-agent planning\n\n## Installation\n\n```bash\npip install axonflow\n```\n\nWith LLM provider support:\n```bash\npip install axonflow[openai]      # OpenAI integration\npip install axonflow[anthropic]   # Anthropic integration\npip install axonflow[all]         # All integrations\n```\n\n## Evaluation Tier (Free License)\n\nNeed more capacity than Community without moving to Enterprise? Evaluation uses the same core features with higher limits:\n\n| Limit | Community | Evaluation (Free) | Enterprise |\n|-------|-----------|-------------------|------------|\n| Tenant policies | 20 | 50 | Unlimited |\n| Org-wide policies | 0 | 5 | Unlimited |\n| Audit retention | 3 days | 14 days | 3650 days |\n| Concurrent executions | 5 | 25 | Unlimited |\n| Pending execution approvals | 5 | 25 | Unlimited |\n| Evidence export (CSV / JSON) | — | 5,000 records · 14d window · 3/day | Unlimited |\n| Policy simulation | — | 300 / day | Unlimited |\n\nConcurrent executions applies to MAP and WCP executions per tenant. Pending execution approvals applies to MAP confirm/step mode and WCP approval queues.\n\n\u003e **Note:** Evidence export and policy simulation are licensed AxonFlow platform capabilities available alongside the SDK on your deployed platform — not language-specific SDK helpers. Access them via the platform API or customer portal. The SDK row is included to show what your licensed deployment unlocks at each tier.\n\n[Get a free Evaluation license](https://getaxonflow.com/evaluation-license?utm_source=readme_sdk_python_eval) · [Full feature matrix](https://docs.getaxonflow.com/docs/features/community-vs-enterprise?utm_source=readme_sdk_python_eval)\n\n## Try Without Installing\n\nSkip local setup entirely — try AxonFlow instantly at [**try.getaxonflow.com**](https://docs.getaxonflow.com/docs/deployment/community-saas):\n\n```bash\n# 1. Register (30 seconds)\ncurl -X POST https://try.getaxonflow.com/api/v1/register \\\n  -H \"Content-Type: application/json\" -d '{\"label\":\"my-trial\"}'\n\n# 2. Set credentials and auto-connect\nexport AXONFLOW_TRY=1\nexport AXONFLOW_CLIENT_ID=cs_your-tenant-id\nexport AXONFLOW_CLIENT_SECRET=your-secret\n```\n\nNo Docker, no license, no installation. Rate-limited to 20 req/min. [Learn more](https://docs.getaxonflow.com/docs/deployment/community-saas).\n\n## Quick Start\n\n### Async Usage (Recommended)\n\n```python\nimport asyncio\nfrom axonflow import AxonFlow\n\nasync def main():\n    async with AxonFlow(\n        endpoint=\"https://your-agent.axonflow.com\",\n        client_id=\"your-client-id\",\n        client_secret=\"your-client-secret\"\n    ) as client:\n        # Execute a governed query\n        response = await client.proxy_llm_call(\n            user_token=\"user-jwt-token\",\n            query=\"What is AI governance?\",\n            request_type=\"chat\"\n        )\n        print(response.data)\n\nasyncio.run(main())\n```\n\n### Sync Usage\n\n```python\nfrom axonflow import AxonFlow\n\nwith AxonFlow.sync(\n    endpoint=\"https://your-agent.axonflow.com\",\n    client_id=\"your-client-id\",\n    client_secret=\"your-client-secret\"\n) as client:\n    response = client.proxy_llm_call(\n        user_token=\"user-jwt-token\",\n        query=\"What is AI governance?\",\n        request_type=\"chat\"\n    )\n    print(response.data)\n```\n\n## Features\n\n### Gateway Mode\n\nFor lowest-latency LLM calls with full governance and audit compliance:\n\n```python\nfrom axonflow import AxonFlow, TokenUsage\n\nasync with AxonFlow(...) as client:\n    # 1. Pre-check: Get policy approval\n    ctx = await client.get_policy_approved_context(\n        user_token=\"user-jwt\",\n        query=\"Find patient records\",\n        data_sources=[\"postgres\"]\n    )\n\n    if not ctx.approved:\n        raise Exception(f\"Blocked: {ctx.block_reason}\")\n\n    # 2. Make LLM call directly (your code)\n    llm_response = await openai.chat.completions.create(\n        model=\"gpt-4\",\n        messages=[{\"role\": \"user\", \"content\": str(ctx.approved_data)}]\n    )\n\n    # 3. Audit the call\n    await client.audit_llm_call(\n        context_id=ctx.context_id,\n        response_summary=llm_response.choices[0].message.content[:100],\n        provider=\"openai\",\n        model=\"gpt-4\",\n        token_usage=TokenUsage(\n            prompt_tokens=llm_response.usage.prompt_tokens,\n            completion_tokens=llm_response.usage.completion_tokens,\n            total_tokens=llm_response.usage.total_tokens\n        ),\n        latency_ms=250\n    )\n```\n\n### OpenAI Integration\n\nTransparent governance for existing OpenAI code:\n\n```python\nfrom openai import OpenAI\nfrom axonflow import AxonFlow\nfrom axonflow.interceptors.openai import wrap_openai_client\n\nopenai = OpenAI()\naxonflow = AxonFlow(...)\n\n# Wrap client - governance is now automatic\nwrapped = wrap_openai_client(openai, axonflow, user_token=\"user-123\")\n\n# Use as normal\nresponse = wrapped.chat.completions.create(\n    model=\"gpt-4\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\n```\n\n### MCP Connectors\n\nQuery data through MCP connectors:\n\n```python\n# List available connectors\nconnectors = await client.list_connectors()\n\n# Query a connector\nresult = await client.query_connector(\n    user_token=\"user-jwt\",\n    connector_name=\"postgres\",\n    operation=\"query\",\n    params={\"sql\": \"SELECT * FROM users LIMIT 10\"}\n)\n```\n\n### MCP Policy Features (v3.2.0)\n\n**Exfiltration Detection** - Prevent large-scale data extraction:\n\n```python\n# Query with exfiltration limits (default: 10K rows, 10MB)\nresult = await client.query_connector(\n    user_token=\"user-jwt\",\n    connector_name=\"postgres\",\n    operation=\"query\",\n    params={\"sql\": \"SELECT * FROM customers\"}\n)\n\n# Check exfiltration info\nif result.policy_info.exfiltration_check.exceeded:\n    print(f\"Limit exceeded: {result.policy_info.exfiltration_check.limit_type}\")\n\n# Configure: MCP_MAX_ROWS_PER_QUERY=1000, MCP_MAX_BYTES_PER_QUERY=5242880\n```\n\n**Dynamic Policy Evaluation** - Orchestrator-based rate limiting, budget controls:\n\n```python\n# Response includes dynamic policy info when enabled\nif result.policy_info.dynamic_policy_info.orchestrator_reachable:\n    print(f\"Policies evaluated: {result.policy_info.dynamic_policy_info.policies_evaluated}\")\n    for policy in result.policy_info.dynamic_policy_info.matched_policies:\n        print(f\"  {policy.policy_name}: {policy.action}\")\n\n# Enable: MCP_DYNAMIC_POLICIES_ENABLED=true\n```\n\n### Multi-Agent Planning\n\nGenerate and execute multi-agent plans:\n\n```python\n# Generate a plan\nplan = await client.generate_plan(\n    query=\"Book a flight and hotel for my trip to Paris\",\n    domain=\"travel\"\n)\n\nprint(f\"Plan has {len(plan.steps)} steps\")\n\n# Execute the plan\nresult = await client.execute_plan(plan.plan_id)\nprint(f\"Result: {result.result}\")\n```\n\n## Configuration\n\n```python\nfrom axonflow import AxonFlow, Mode, RetryConfig\n\nclient = AxonFlow(\n    endpoint=\"https://your-agent.axonflow.com\",\n    client_id=\"your-client-id\",               # Required for enterprise features\n    client_secret=\"your-client-secret\",       # Required for enterprise features\n    mode=Mode.PRODUCTION,                     # or Mode.SANDBOX\n    debug=True,                               # Enable debug logging\n    timeout=60.0,                             # Request timeout in seconds\n    retry_config=RetryConfig(                 # Retry configuration\n        enabled=True,\n        max_attempts=3,\n        initial_delay=1.0,\n        max_delay=30.0,\n    ),\n    cache_enabled=True,                       # Enable response caching\n    cache_ttl=60.0,                           # Cache TTL in seconds\n)\n```\n\n## Error Handling\n\n```python\nfrom axonflow.exceptions import (\n    AxonFlowError,\n    PolicyViolationError,\n    AuthenticationError,\n    RateLimitError,\n    TimeoutError,\n)\n\ntry:\n    response = await client.proxy_llm_call(...)\nexcept PolicyViolationError as e:\n    print(f\"Blocked by policy: {e.block_reason}\")\nexcept RateLimitError as e:\n    print(f\"Rate limited: {e.limit}/{e.remaining}, resets at {e.reset_at}\")\nexcept AuthenticationError:\n    print(\"Invalid credentials\")\nexcept TimeoutError:\n    print(\"Request timed out\")\nexcept AxonFlowError as e:\n    print(f\"AxonFlow error: {e.message}\")\n```\n\n## Response Types\n\nAll responses are Pydantic models with full type hints:\n\n```python\nfrom axonflow import (\n    ClientResponse,\n    PolicyApprovalResult,\n    PlanResponse,\n    ConnectorResponse,\n)\n\n# Full autocomplete and type checking support\nresponse: ClientResponse = await client.proxy_llm_call(...)\nprint(response.success)\nprint(response.data)\nprint(response.policy_info.policies_evaluated)\n```\n\n## Development\n\n```bash\n# Install dev dependencies\npip install -e \".[dev]\"\n\n# Run tests\npytest\n\n# Run linting\nruff check .\nruff format .\n\n# Run type checking\nmypy axonflow\n```\n\n## Examples\n\nComplete working examples for all features are available in the [examples folder](https://github.com/getaxonflow/axonflow/tree/main/examples).\n\n### Community Features\n\n```python\n# PII Detection - Automatically detect sensitive data\nresult = await client.get_policy_approved_context(\n    user_token=\"user-123\",\n    query=\"My SSN is 123-45-6789\"\n)\n# result.approved = True, result.requires_redaction = True (SSN detected)\n\n# SQL Injection Detection - Block malicious queries\nresult = await client.get_policy_approved_context(\n    user_token=\"user-123\",\n    query=\"SELECT * FROM users; DROP TABLE users;\"\n)\n# result.approved = False, result.block_reason = \"SQL injection detected\"\n\n# Static Policies - List and manage built-in policies\npolicies = await client.list_policies()\n# Returns: [Policy(name=\"pii-detection\", enabled=True), ...]\n\n# Dynamic Policies - Create runtime policies\nawait client.create_dynamic_policy(\n    name=\"block-competitor-queries\",\n    conditions={\"contains\": [\"competitor\", \"pricing\"]},\n    action=\"block\"\n)\n\n# MCP Connectors - Query external data sources\nresp = await client.query_connector(\n    user_token=\"user-123\",\n    connector_name=\"postgres-db\",\n    operation=\"query\",\n    params={\"sql\": \"SELECT name FROM customers\"}\n)\n\n# Multi-Agent Planning - Orchestrate complex workflows\nplan = await client.generate_plan(\n    query=\"Research AI governance regulations\",\n    domain=\"legal\"\n)\nresult = await client.execute_plan(plan.plan_id)\n\n# Audit Logging - Track all LLM interactions\nawait client.audit_llm_call(\n    context_id=ctx.context_id,\n    response_summary=\"AI response summary\",\n    provider=\"openai\",\n    model=\"gpt-4\",\n    token_usage=TokenUsage(prompt_tokens=100, completion_tokens=200, total_tokens=300),\n    latency_ms=450\n)\n```\n\n### Enterprise Features\n\nThese features require an AxonFlow Enterprise license:\n\n```python\n# Code Governance - Automated PR reviews with AI\npr_result = await client.review_pull_request(\n    repo_owner=\"your-org\",\n    repo_name=\"your-repo\",\n    pr_number=123,\n    check_types=[\"security\", \"style\", \"performance\"]\n)\n\n# Cost Controls - Budget management for LLM usage\nbudget = await client.get_budget(\"team-engineering\")\n# Returns: Budget(limit=1000.00, used=234.56, remaining=765.44)\n\n# MCP Policy Enforcement - Automatic PII redaction in connector responses\nresp = await client.query_connector(\"user\", \"postgres\", \"SELECT * FROM customers\", {})\n# resp.policy_info.redacted = True\n# resp.policy_info.redacted_fields = [\"ssn\", \"credit_card\"]\n```\n\nFor enterprise features, contact [sales@getaxonflow.com](mailto:sales@getaxonflow.com).\n\n## Documentation\n\n- [Getting Started](https://docs.getaxonflow.com/docs/sdk/python-getting-started)\n- [Gateway Mode Guide](https://docs.getaxonflow.com/docs/sdk/gateway-mode)\n\n## Support\n\n- **Documentation**: https://docs.getaxonflow.com\n- **Issues**: https://github.com/getaxonflow/axonflow-sdk-python/issues\n- **Email**: hello@getaxonflow.com\n\nIf you are evaluating AxonFlow in a company setting and cannot open a public issue, you can share feedback or blockers confidentially here:\n[Anonymous evaluation feedback form](https://getaxonflow.com/feedback)\n\nNo email required. Optional contact if you want a response.\n\n## Telemetry\n\nThis SDK sends anonymous usage telemetry (SDK version, OS, enabled features) to help improve AxonFlow.\nNo prompts, payloads, or PII are ever collected. Opt out: `AXONFLOW_TELEMETRY=off`.\n\n`DO_NOT_TRACK` is **not** honored as an opt-out for AxonFlow telemetry. It is commonly inherited from host tools and developer environments, which makes it an unreliable expression of user intent.\n\nSee [Telemetry Documentation](https://docs.getaxonflow.com/docs/telemetry) for full details.\n\n## License\n\nMIT - See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetaxonflow%2Faxonflow-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetaxonflow%2Faxonflow-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetaxonflow%2Faxonflow-sdk-python/lists"}