> ## Documentation Index
> Fetch the complete documentation index at: https://metorial.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Learn how to use the Metorial Python SDK for Python applications

<Note>
  **What you'll learn:**

  * How to install the Metorial Python SDK
  * How to make requests to the Metorial API using the SDK

  **Before you start:**

  * [Create your API Keys](/api-getting-started)

  **External resources:**

  * [Python SDK on GitHub](https://github.com/metorial/metorial-python)
</Note>

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.

<Info>
  **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.
</Info>

<Steps>
  <Step title="Install the SDK">
    Install the SDK using pip:

    ```bash theme={null}
    pip install metorial
    ```
  </Step>

  <Step title="Using the SDK">
    To use the SDK, import the `Metorial` class and create an instance with your API key:

    ```python theme={null}
    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.
  </Step>

  <Step title="Making Requests">
    Connect to your deployed providers using `metorial.connect()`. Pass an adapter for your chosen AI provider and a list of provider deployments:

    ```python theme={null}
    from metorial import Metorial, metorial_openai

    async def main():
        session = await metorial.connect(
            adapter=metorial_openai(),
            providers=[{"provider_deployment_id": "your-provider-deployment-id"}],
        )

        # 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())
    ```
  </Step>

  <Step title="Using Types">
    The SDK includes type hints for all API resources. Use tools like mypy or your IDE's type checker to catch errors before runtime and get autocomplete suggestions for all API methods and parameters.
  </Step>
</Steps>
