Skip to main content

Python SDK for Metorial - The open source integration platform for agentic AI

Project description

Metorial Python SDK

The official Python SDK for Metorial - Connect your AI agents to any MCP server with a single line of code. Deploy tools like Slack, GitHub, SAP, and hundreds more without managing infrastructure.

Sign up for a free account to get started.

Complete API Documentation

API Documentation - Complete API reference and guides

Available Providers

Provider Import Format Models (non-exhaustive)
OpenAI MetorialOpenAI OpenAI function calling gpt-4.1, gpt-4o, o1, o3
Anthropic MetorialAnthropic Claude tool format claude-sonnet-4-5, claude-opus-4
Google MetorialGoogle Gemini function declarations gemini-2.5-pro, gemini-2.5-flash
Mistral MetorialMistral Mistral function calling mistral-large-latest, codestral-latest
DeepSeek MetorialDeepSeek OpenAI-compatible deepseek-chat, deepseek-reasoner
TogetherAI MetorialTogetherAI OpenAI-compatible Llama-4, Qwen-3
XAI MetorialXAI OpenAI-compatible grok-3, grok-3-mini
LangChain MetorialLangChain LangChain tools Any model via LangChain
OpenAI-Compatible MetorialOpenAICompatible OpenAI-compatible Any OpenAI-compatible API

Installation

pip install metorial

Quick Start

pip install metorial anthropic
import asyncio
from metorial import Metorial, MetorialAnthropic
from anthropic import AsyncAnthropic

metorial = Metorial(api_key="your-metorial-api-key")
anthropic = AsyncAnthropic(api_key="your-anthropic-api-key")

async def main():
    async def session_handler(session):
        messages = [{"role": "user", "content": "What's the latest news on Hacker News?"}]

        for _ in range(10):
            response = await anthropic.messages.create(
                model="claude-sonnet-4-5",
                max_tokens=1024,
                messages=messages,
                tools=session["tools"]
            )

            tool_calls = [b for b in response.content if b.type == "tool_use"]
            if not tool_calls:
                print(response.content[0].text)
                break

            tool_responses = await session["callTools"](tool_calls)
            messages.append({"role": "assistant", "content": response.content})
            messages.append(tool_responses)

        await session["closeSession"]()

    await metorial.with_provider_session(
        MetorialAnthropic,
        {"serverDeployments": [{"serverDeploymentId": "your-server-deployment-id"}]},
        session_handler
    )

asyncio.run(main())

Session Options

Streaming Mode

When using streaming with tool calls, enable the streaming flag:

await metorial.with_provider_session(
    metorial_provider,
    {
        "serverDeployments": [...],
        "streaming": True,  # Required for streaming with tool calls
    },
    session_handler
)

Closing Sessions

Always close your session when done to free up resources:

async def session_handler(session):
    tools = session["tools"]
    close_session = session["closeSession"]

    # Use tools...

    # When finished, close the session
    await close_session()

Session Object

The session object passed to your callback provides:

async def session_handler(session):
    tools = session["tools"]           # Tool definitions formatted for your provider
    call_tools = session["callTools"]  # Execute tools and get responses
    close_session = session["closeSession"]  # Close the session when done (always call this!)

Error Handling

from metorial import MetorialAPIError

try:
    await metorial.with_provider_session(...)
except MetorialAPIError as e:
    print(f"API Error: {e.message} (Status: {e.status})")
except Exception as e:
    print(f"Unexpected error: {e}")

License

MIT License - see LICENSE file for details.

Support

Documentation · GitHub Issues · Email Support

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.12.tar.gz (8.4 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.12-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file metorial-1.0.12.tar.gz.

File metadata

  • Download URL: metorial-1.0.12.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metorial-1.0.12.tar.gz
Algorithm Hash digest
SHA256 4d3e3209d65e9bc4cb02b6cb692306d9952c6a6e224434b5c116f56b91f902bd
MD5 253bc83b93eee50dc0b88db3c21554eb
BLAKE2b-256 7078aba14a517bf8ecf5cb37106ee97047d5ed7a176f0aa7405d8718a978bb93

See more details on using hashes here.

Provenance

The following attestation bundles were made for metorial-1.0.12.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.12-py3-none-any.whl.

File metadata

  • Download URL: metorial-1.0.12-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metorial-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 a9a771a18357eb8be899c2024790afc1fcd1bffdb3cbbcf2f932b3ef13282e79
MD5 0b0f702f11219f1e88f6ec8e21d1aa4c
BLAKE2b-256 ba277d0750dc7cbad74a02c314a50b9455224a12f99e00be931b513a7f5d9b79

See more details on using hashes here.

Provenance

The following attestation bundles were made for metorial-1.0.12-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