Python SDK for Metorial - AI-powered tool calling and session management
Project description
metorial
The main Python client for Metorial - The open source integration platform for agentic AI. This is the primary package that provides the core client and session management functionality.
Installation
pip install metorial
# or
uv add metorial
# or
poetry add metorial
Features
- 🔧 Multi-Provider Support: Use the same tools across different AI providers
- 🚀 Easy Integration: Simple async/await interface
- 📡 Session Management: Automatic session lifecycle handling
- 🛠️ Tool Discovery: Automatic tool detection and formatting
- 🔄 Format Conversion: Provider-specific tool format conversion
Supported Providers
- ✅ OpenAI (GPT-4, GPT-3.5)
- ✅ Anthropic (Claude)
- ✅ Google (Gemini)
- ✅ Mistral AI
- ✅ DeepSeek
- ✅ Together AI
- ✅ XAI (Grok)
Usage
Basic Usage
import asyncio
from metorial import Metorial
async def main():
# Initialize Metorial client
metorial = Metorial(api_key="your-metorial-api-key")
# Create session with your server deployments
async with metorial.session(["your-server-deployment-id"]) as session:
# Access tool manager
tool_manager = session.tool_manager
# Use with provider-specific packages
# See provider packages for specific integrations
asyncio.run(main())
With Provider Packages
Use metorial with provider-specific packages:
import asyncio
from metorial import Metorial
from metorial_openai import MetorialOpenAISession
from openai import OpenAI
async def main():
# Initialize clients
metorial = Metorial(api_key="your-metorial-api-key")
openai_client = OpenAI(api_key="your-openai-api-key")
# Create session
async with metorial.session(["deployment-id"]) as session:
# Use with OpenAI
openai_session = MetorialOpenAISession(session.tool_manager)
response = openai_client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Help me"}],
tools=openai_session.tools
)
# Handle tool calls
if response.choices[0].message.tool_calls:
tool_responses = await openai_session.call_tools(
response.choices[0].message.tool_calls
)
asyncio.run(main())
API Reference
Metorial
Main client class for Metorial.
client = Metorial(api_key="your-api-key")
Parameters:
api_key: Your Metorial API key
Methods:
async session(deployment_ids): Create a session with specified deployments
Session Context Manager
async with metorial.session(["deployment-id"]) as session:
# session.tool_manager provides access to tools
Properties:
tool_manager: Manager for executing tools
Provider Integration
This package works with provider-specific packages:
metorial-openai: OpenAI integrationmetorial-anthropic: Anthropic (Claude) integrationmetorial-google: Google (Gemini) integrationmetorial-mistral: Mistral AI integrationmetorial-xai: XAI (Grok) integrationmetorial-deepseek: DeepSeek integrationmetorial-togetherai: Together AI integration
Error Handling
from metorial import MetorialAPIError
try:
async with metorial.session(["deployment-id"]) as session:
# Your code here
pass
except MetorialAPIError as e:
print(f"API Error: {e.message} (Status: {e.status})")
except Exception as e:
print(f"Unexpected error: {e}")
Configuration
Environment Variables
You can also configure the client using environment variables:
export METORIAL_API_KEY="your-api-key"
# Will use METORIAL_API_KEY if no api_key provided
metorial = Metorial()
Dependencies
metorial-core>=1.0.0metorial-mcp-session>=1.0.0typing-extensions>=4.0.0
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metorial-1.0.0rc2.tar.gz.
File metadata
- Download URL: metorial-1.0.0rc2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79c90373525e4db80997a9a33546df38db82b4f470a12ca6cb4b08f070111542
|
|
| MD5 |
8f9b95bec4a2aa3eb68c348896614c6e
|
|
| BLAKE2b-256 |
e33aa2a04691c6fadfadc67fb462e889c06607ffcebc577b28b3151ef5fb1cf9
|
Provenance
The following attestation bundles were made for metorial-1.0.0rc2.tar.gz:
Publisher:
release.yml on metorial/metorial-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metorial-1.0.0rc2.tar.gz -
Subject digest:
79c90373525e4db80997a9a33546df38db82b4f470a12ca6cb4b08f070111542 - Sigstore transparency entry: 314690068
- Sigstore integration time:
-
Permalink:
metorial/metorial-python@5e8e01f7466e5109eaea700c35db0ebbedaa3f5d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/metorial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e8e01f7466e5109eaea700c35db0ebbedaa3f5d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file metorial-1.0.0rc2-py3-none-any.whl.
File metadata
- Download URL: metorial-1.0.0rc2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf3bd68e6068b6d24881822ccb88e3a8619c8ccb1a2a0d1681760220091cfed7
|
|
| MD5 |
903fbef5ca60363c042ccf68e084d8bf
|
|
| BLAKE2b-256 |
9c2a01a9a444ce41018eb2d98e402eb7738618ed14ff74350a4ea55069c4b2a3
|
Provenance
The following attestation bundles were made for metorial-1.0.0rc2-py3-none-any.whl:
Publisher:
release.yml on metorial/metorial-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metorial-1.0.0rc2-py3-none-any.whl -
Subject digest:
cf3bd68e6068b6d24881822ccb88e3a8619c8ccb1a2a0d1681760220091cfed7 - Sigstore transparency entry: 314690080
- Sigstore integration time:
-
Permalink:
metorial/metorial-python@5e8e01f7466e5109eaea700c35db0ebbedaa3f5d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/metorial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e8e01f7466e5109eaea700c35db0ebbedaa3f5d -
Trigger Event:
workflow_dispatch
-
Statement type: