What you’ll learn:
- How to install the Metorial SDK
- Available AI providers and integrations
- How to create sessions and use tools
- OAuth flow for authenticated services
Prerequisites
- Metorial API key: Get one from app.metorial.com
- Provider deployment ID: Deploy a provider (e.g., Exa for search) from the dashboard
- AI provider API key: OpenAI, Anthropic, Google, etc.
Installation
The Metorial SDK consists of two parts: the core SDK (which handles sessions and tool management) and a provider package (which integrates with your chosen AI model). Install both to get started.Your First AI Agent
This example shows how to create an AI agent that can use tools from your deployed providers. The agent will have access to any tools provided by your provider deployment (like search, file operations, or API calls). What this code does:- Initializes the Metorial SDK with your API key
- Creates a session connected to your provider deployment
- Passes the available tools to your AI model
- Handles tool calls in an agentic loop
OAuth Flow
For services requiring user authentication (like Slack, GitHub, or Google Calendar), use a Provider Setup Session to authorize your users. The resulting Provider Auth Config stores their credentials for reuse. The flow:- Create a Provider Setup Session for each service that needs authentication
- Redirect your user to the session URL to complete OAuth
- Wait for the setup session to complete — you get back an auth config
- Pass the auth config ID when creating sessions for that user
Error Handling
The Metorial SDK provides specific error types to help you handle different failure scenarios. CatchMetorialAPIError for API-related issues like authentication failures, rate limits, or invalid deployment IDs.