Skip to main content

Example

import { Metorial } from 'metorial';
import { metorialAnthropic } from '@metorial/anthropic';
import Anthropic from '@anthropic-ai/sdk';

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

await metorial.withProviderSession(
    metorialAnthropic,
    { serverDeployments: [{ serverDeploymentId: 'your-deployment-id' }] },
    async ({ tools, callTools, closeSession }) => {
        let response = await anthropic.messages.create({
            model: 'claude-sonnet-4-5',
            max_tokens: 1024,
            messages: [{ role: 'user', content: 'Help me' }],
            tools: tools
        });

        await closeSession();
    }
);