Observed since 21 Oct, 11:18 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Professional Python SDK for Mesh AI Platform
Professional Python SDK for the Mesh AI Platform. Easily integrate AI agents, tools, and LLMs into your Python applications with both synchronous and asynchronous support.
pip install ai-mesh-sdk
# With LangChain integration
pip install ai-mesh-sdk[langchain]
# For development
pip install ai-mesh-sdk[dev]
# All optional dependencies
pip install ai-mesh-sdk[langchain,dev]
import os
from mesh_sdk import MeshClient
# Initialize the client
client = MeshClient(api_key=os.getenv("MESH_API_KEY"))
# List available agents
agents = client.list_agents()
print(f"Found {len(agents)} agents")
# Call an agent
response = client.call_agent(
agent_id="your-agent-id",
inputs={"query": "What is the weather today?"}
)
print(response.data)
# Chat completions (OpenAI-compatible)
messages = [{"role": "user", "content": "Hello!"}]
response = client.chat_completions(
model="gpt-3.5-turbo",
messages=messages,
temperature=0.7
)
print(response.choices[0].message.content)
import asyncio
from mesh_sdk import AsyncMeshClient
async def main():
# Initialize async client
async with AsyncMeshClient(api_key=os.getenv("MESH_API_KEY")) as client:
# List agents asynchronously
agents = await client.list_agents()
print(f"Found {len(agents)} agents")
# Call agent asynchronously
response = await client.call_agent(
agent_id="your-agent-id",
inputs={"query": "Analyze this data"}
)
print(response.data)
# Async chat completions
messages = [{"role": "user", "content": "Hello!"}]
response = await client.chat_completions(
model="gpt-4",
messages=messages
)
print(response.choices[0].message.content)
# Run the async function
asyncio.run(main())
# Streaming chat completions
messages = [{"role": "user", "content": "Tell me a story"}]
for chunk in client.chat_completions(
model="gpt-3.5-turbo",
messages=messages,
stream=True
):
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
The Mesh platform supports three types of agents:
Direct access to language models via OpenAI-compatible chat completions:
# List available LLMs
llms = client.list_llms()
# Use with chat completions
response = client.chat_completions(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)
Specialized functions that perform specific tasks:
# List available tools
tools = client.list_tools()
# Call a tool
response = client.call_agent(
agent_id="search-tool-123",
inputs={"query": "Python programming", "max_results": 10}
)
Complex workflows that can use multiple tools and make decisions:
# List workflow agents
workflows = client.list_workflow_agents()
# Execute a workflow
response = client.call_agent(
agent_id="data-analysis-workflow-456",
inputs={"dataset_url": "https://example.com/data.csv"}
)
Mesh SDK provides seamless integration with LangChain:
from mesh_sdk import MeshClient
from mesh_sdk.integrations.langchain import to_langchain_tools
# Initialize client
client = MeshClient(api_key="your-api-key")
# Convert Mesh agents to LangChain tools
tools = to_langchain_tools(client)
# Use with LangChain agents
from langchain.agents import create_react_agent, AgentExecutor
from langchain import hub
# Get a prompt template
prompt = hub.pull("hwchase17/react")
# Create LangChain agent (you'll need a separate LLM)
agent = create_react_agent(your_llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Execute
response = agent_executor.invoke({
"input": "Search for information about climate change"
})
export MESH_API_KEY="your-api-key-here"
export MESH_BASE_URL="https://api.meshcore.ai" # Optional, defaults to official API
from mesh_sdk import MeshClient
client = MeshClient(
api_key="your-api-key",
base_url="https://api.meshcore.ai", # Custom API endpoint
timeout=60.0, # Request timeout in seconds
max_retries=3, # Max retries for failed requests
retry_delay=1.0 # Base delay between retries
)
The SDK provides specific exceptions for different error scenarios:
from mesh_sdk import MeshClient
from mesh_sdk.exceptions import (
AuthenticationError,
AuthorizationError,
RateLimitError,
ValidationError,
APIError,
NetworkError,
TimeoutError
)
client = MeshClient(api_key="your-api-key")
try:
agents = client.list_agents()
except AuthenticationError:
print("Invalid API key")
except AuthorizationError:
print("Access denied")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except ValidationError as e:
print(f"Invalid input: {e}")
except NetworkError:
print("Network connection failed")
except TimeoutError:
print("Request timed out")
except APIError as e:
print(f"API error: {e}")
The SDK uses Python's standard logging module:
import logging
# Enable debug logging
logging.basicConfig(level=logging.DEBUG)
# Or configure specific logger
logger = logging.getLogger('mesh_sdk')
logger.setLevel(logging.INFO)
git clone https://github.com/your-org/mesh-sdk.git
cd mesh-sdk
pip install -e .[dev]
# Run all tests
pytest
# Run with coverage
pytest --cov=mesh_sdk --cov-report=html
# Run specific test file
pytest tests/test_client.py
# Format code
black src/ tests/
# Lint code
ruff src/ tests/
# Type checking
mypy src/
pip install pre-commit
pre-commit install
See the examples/ directory for complete example applications:
The main synchronous client for the Mesh API.
list_agents() → List[Agent] - List all agents and tools (excluding LLMs)list_tools() → List[Agent] - List only toolslist_workflow_agents() → List[Agent] - List only workflow agentslist_all_agents() → List[Agent] - List all agent types including LLMslist_llms() → List[Agent] - List only LLMscall_agent(agent_id, inputs, validate_inputs=True) → AgentResponse - Call an agentchat_completions(model, messages, **kwargs) → ChatCompletionResponse - Create chat completionAsynchronous version of MeshClient with the same methods as async functions.
Agent - Represents an agent, tool, or LLMChatMessage - Individual chat messageChatCompletionRequest - Request for chat completionsChatCompletionResponse - Response from chat completionsAgentResponse - Response from agent callsWe welcome contributions! Please see our Contributing Guidelines for details.
git checkout -b feature/amazing-feature)pytest)black, ruff, mypy)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a detailed history of changes.
Made with ❤️ by the Mesh AI Team
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 10 Aug 2025 | 12 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 11:18 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:78e523042c76864f58fa7eb9223729ba2b808194568c12e3da6e18b3554decc9