Skip to main content

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 integration
  • metorial-anthropic: Anthropic (Claude) integration
  • metorial-google: Google (Gemini) integration
  • metorial-mistral: Mistral AI integration
  • metorial-xai: XAI (Grok) integration
  • metorial-deepseek: DeepSeek integration
  • metorial-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.0
  • metorial-mcp-session>=1.0.0
  • typing-extensions>=4.0.0

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metorial-1.0.0rc1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metorial-1.0.0rc1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file metorial-1.0.0rc1.tar.gz.

File metadata

  • Download URL: metorial-1.0.0rc1.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

Hashes for metorial-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 fe0c8a5f845efcde92f90b44022dc0922b8eb4420f0dd64d295196532a951955
MD5 d6b045323611afd3aedde12b8d1d64af
BLAKE2b-256 cc4328b471616bc92b680c2f8aa4d9b3801102f5e890a066731d1b354d976842

See more details on using hashes here.

Provenance

The following attestation bundles were made for metorial-1.0.0rc1.tar.gz:

Publisher: release.yml on metorial/metorial-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metorial-1.0.0rc1-py3-none-any.whl.

File metadata

  • Download URL: metorial-1.0.0rc1-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

Hashes for metorial-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ca0f4d2044dd758b0cc62e9defab07f509d2cd32949ae05c4c791bb9bfbd202
MD5 02bef6fbd612feda22c2b78271306296
BLAKE2b-256 174519f2f2a9b4a6bce698eae41708edef3352f991eade801664e3a69e72702d

See more details on using hashes here.

Provenance

The following attestation bundles were made for metorial-1.0.0rc1-py3-none-any.whl:

Publisher: release.yml on metorial/metorial-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page