| title | description |
|---|---|
Python SDK |
Learn how to use the Metorial Python SDK for Python applications |
- How to install the Metorial Python SDK
- How to make requests to the Metorial API using the SDK
Before you start:
External resources:
The Metorial Python SDK provides a Pythonic interface for interacting with the Metorial API. Use it to manage provider deployments, create sessions, handle OAuth flows, and integrate MCP tools into your Python applications.
The SDK is fully typed with type hints for all methods and resources, making it ideal for use with modern Python development tools.
**Explore Python Examples:** Check out practical examples and sample code in the [metorial-python examples directory](https://github.com/metorial/metorial-python/tree/main/examples) on GitHub. Install the SDK using pip:```bash
pip install metorial
```
```python
import asyncio
from metorial import Metorial
metorial = Metorial(api_key="your-api-key")
```
You can now use the `metorial` instance to make requests to the Metorial API.
```python
async def main():
async with metorial.provider_session(
provider="openai", # Tool format: "openai", "anthropic", "google", etc.
providers=[{"provider_deployment_id": "your-provider-deployment-id"}],
) as session:
# See your available tools
for tool in session.tools:
print(f"- {tool['function']['name']}")
# Call a tool directly
result = await session.call_tool("search", {"query": "python news"})
print(result)
asyncio.run(main())
```