# Using with AI SDK
URL: https://metorial.com/docs/build/providers/ai-sdk

Use Metorial with Vercel AI SDK (recommended for TypeScript)

---

The Vercel AI SDK integration (`@metorial/ai-sdk`) is the recommended way to use Metorial in TypeScript applications. It provides excellent streaming support, a unified interface across multiple model providers, and seamless tool integration.

This integration works with any model provider supported by the AI SDK, including Anthropic, OpenAI, Google, and more. You get all the benefits of the AI SDK's streaming and tool handling while Metorial manages your provider connections.

**What this example does:**

1. Creates a Metorial session connected to your provider deployment
2. Passes MCP tools directly to the AI SDK's `streamText` function
3. Streams the AI's response in real-time

## Example [#example]

<CodeBlockTabs defaultValue="TypeScript" mode="code">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="TypeScript">
      TypeScript
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="Python">
      Python
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="TypeScript">
    ```typescript
    import { Metorial } from 'metorial';
    import { metorialAiSdk } from '@metorial/ai-sdk';
    import { anthropic } from '@ai-sdk/anthropic';
    import { streamText } from 'ai';

    let metorial = new Metorial({
    	apiKey: process.env.METORIAL_API_KEY
    });

    let session = await metorial.connect({
      adapter: metorialAiSdk(),
      providers: [{ providerDeploymentId: 'your-provider-deployment-id' }]
    });


    let result = streamText({
      model: anthropic("claude-sonnet-4-20250514"),
      prompt: "Help me",
      tools: session.tools(),
    });

    for await (let text of result.textStream) {
      process.stdout.write(text);
    }
    ```
  </CodeBlockTab>

  <CodeBlockTab value="Python">
    ```python
    # AI SDK is TypeScript-only
    # Use provider-specific client for Python (see Anthropic, OpenAI pages)
    ```
  </CodeBlockTab>
</CodeBlockTabs>