Metadata-Version: 2.4
Name: m2m-market
Version: 0.1.0
Summary: Customer SDK for connecting AI Agents to M2M Market
Project-URL: Documentation, https://github.com/castronyabola/m2m-marketplace-mvp/tree/main/m2m-marketplace-mvp/sdk
Project-URL: Source, https://github.com/castronyabola/m2m-marketplace-mvp
Author: M2M Market
License: Proprietary
Keywords: ai-agent,api-marketplace,machine-to-machine,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: requests<3,>=2.31
Provides-Extra: all
Requires-Dist: autogen-agentchat<1,>=0.4; extra == 'all'
Requires-Dist: crewai<2,>=0.100; extra == 'all'
Requires-Dist: langchain-core<2,>=0.3; extra == 'all'
Requires-Dist: openai<3,>=1.0; extra == 'all'
Provides-Extra: autogen
Requires-Dist: autogen-agentchat<1,>=0.4; extra == 'autogen'
Provides-Extra: crewai
Requires-Dist: crewai<2,>=0.100; extra == 'crewai'
Provides-Extra: langchain
Requires-Dist: langchain-core<2,>=0.3; extra == 'langchain'
Provides-Extra: openai
Requires-Dist: openai<3,>=1.0; extra == 'openai'
Description-Content-Type: text/markdown

# M2M Market Python SDK

Connect an existing AI Agent to M2M Market with a revocable connection credential.

## Install

```bash
pip install m2m-market
```

Optional framework integrations:

```bash
pip install "m2m-market[langchain]"
pip install "m2m-market[openai]"
pip install "m2m-market[crewai]"
pip install "m2m-market[autogen]"
```

## Configure

```bash
export M2M_API_BASE_URL="https://4o4666j5va.execute-api.us-east-1.amazonaws.com/dev"
export M2M_CONNECTION_TOKEN="m2m_live_conn-..."
```

## Execute a service

```python
from m2m_market import ConnectionExecutionPolicy, M2MConnectionClient

client = M2MConnectionClient.from_environment()
result = client.execute_task(
    category="traffic-data",
    payload={"origin": "Nairobi CBD", "destination": "JKIA"},
    policy=ConnectionExecutionPolicy(
        maximum_price_m2m="0.05",
        maximum_attempts=2,
    ),
)
print(result["response"])
```

## Test the connection

```python
from m2m_market import M2MConnectionClient

print(M2MConnectionClient.from_environment().test_connection())
```

## OpenAI-compatible tool

```python
from m2m_market import M2MConnectionClient, M2MToolAdapter, openai_tool_definition

adapter = M2MToolAdapter(M2MConnectionClient.from_environment())
tools = [openai_tool_definition()]

# Give `tools` to the model. When it calls purchase_external_service:
result_json = adapter.invoke_json(tool_call.function.arguments)
```

## LangChain

```python
from m2m_market import M2MConnectionClient, M2MToolAdapter

m2m_tool = M2MToolAdapter(
    M2MConnectionClient.from_environment()
).as_langchain_tool()
```

## CrewAI and AutoGen

```python
adapter = M2MToolAdapter(M2MConnectionClient.from_environment())
crewai_tool = adapter.as_crewai_tool()
autogen_function = adapter.as_autogen_function()
```

The dashboard spending policy and owner approval remain authoritative. Request-level limits can only make those controls stricter.
