The simplest way to try Metorial. Uses the Vercel AI SDK with Anthropic Claude to search the web via Metorial's built-in Metorial Search provider — no dashboard setup needed.
METORIAL_API_KEY— get one at platform.metorial.comANTHROPIC_API_KEY— from console.anthropic.com
bun install
bun startimport { anthropic } from '@ai-sdk/anthropic';
import { metorialAiSdk } from '@metorial/ai-sdk';
import { Metorial } from 'metorial';
import { stepCountIs, streamText } from 'ai';
// Initialize the Metorial client and create a deployment for the built-in web search provider.
// `metorial-search` is a special provider slug that works out of the box — no dashboard
// configuration needed.
let metorial = new Metorial({ apiKey: process.env.METORIAL_API_KEY! });
let deployment = await metorial.providerDeployments.create({
name: 'Metorial Search',
providerId: 'metorial-search'
});
// Open a session. `connect()` connects to Metorial's MCP servers and returns an adapter
// session with `tools()` formatted for the AI SDK.
let session = await metorial.connect({
adapter: metorialAiSdk(),
providers: [{ providerDeploymentId: deployment.id }]
});
// Call `streamText()` from the Vercel AI SDK. The AI SDK handles the tool call loop
// automatically — when Claude wants to search the web, it calls the MCP tools, gets
// results, and continues generating. `stepCountIs(10)` limits the number of tool call rounds.
let result = streamText({
model: anthropic('claude-sonnet-4-20250514'),
prompt:
'Search the web for the latest news about AI agents and summarize the top 3 stories.',
stopWhen: stepCountIs(10),
tools: session.tools(),
onStepFinish: step => {
if (step.toolCalls?.length) {
console.log(`\n🔧 ${step.toolCalls.map(tc => tc.toolName).join(', ')}\n`);
}
}
});
// Stream the text to stdout as it arrives.
for await (let part of result.textStream) {
process.stdout.write(part);
}To add providers like GitHub or Slack that require OAuth, see the commented-out OAuth section in the typescript-ai-sdk example, or the main README for full auth docs.