MetorialDocs

Metorial notes for AI code generators and coding agents

The current way to use Metorial in code: metorial 3.x on npm, 2.x on PyPI, metorial.connect() with an adapter, and the names generated code gets wrong.

If you generate code against Metorial, use metorial.connect() with an adapter, metorial 3.x on npm or 2.x on PyPI, and the names on this page. Older posts and examples use names that no longer compile.

What you'll learn

  • The current packages and versions
  • The recommended program in TypeScript and Python
  • Old names and what replaced them

Before you start

Current packages

PackageVersion on 2026-11-22Use
metorial (npm)3.3.6TypeScript and JavaScript SDK
@metorial/ai-sdk3.0.9Adapter for the Vercel AI SDK
@metorial/openai, @metorial/anthropic, @metorial/google3.0.11Adapters for the model SDKs
@metorial/langchain3.0.9Adapter for LangChain and LangGraph
metorial (PyPI)2.7.0, Python 3.10 or laterPython SDK with every adapter built in
@metorial/cli, @metorial/admin0.1.9The metorial and metorial-admin CLIs

Python adapters are functions in the metorial package: metorial_openai, metorial_anthropic, metorial_google, metorial_mistral, metorial_openai_compatible, metorial_langchain, metorial_langgraph, metorial_openai_agents, metorial_llamaindex, metorial_crewai, metorial_google_adk, metorial_pydantic_ai, metorial_autogen and metorial_haystack.

npm install metorial @metorial/ai-sdk ai @ai-sdk/openai
import { openai } from '@ai-sdk/openai';
import { metorialAiSdk } from '@metorial/ai-sdk';
import { generateText, stepCountIs } from 'ai';
import Metorial from 'metorial';

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

let session = await metorial.connect({
  adapter: metorialAiSdk(),
  providers: [{ providerDeploymentId: process.env.METORIAL_PROVIDER_DEPLOYMENT_ID! }]
});

let result = await generateText({
  model: openai('gpt-4o-mini'),
  prompt: 'Search the web for the latest news about AI agents and summarize the top 3 stories.',
  stopWhen: stepCountIs(10),
  tools: session.tools()
});

console.log(result.text);
pip install metorial openai-agents
import asyncio
import os

from agents import Agent, Runner
from metorial import Metorial, metorial_openai_agents


async def main():
    metorial = Metorial(api_key=os.environ["METORIAL_API_KEY"])

    session = await metorial.connect(
        adapter=metorial_openai_agents(),
        providers=[
            {"provider_deployment_id": os.environ["METORIAL_PROVIDER_DEPLOYMENT_ID"]}
        ],
    )

    agent = Agent(
        name="Research assistant",
        instructions="Use the Metorial tools to answer the question.",
        tools=session.tools(),
    )
    result = await Runner.run(
        agent,
        "Search the web for the latest news about AI agents and summarize the top 3 stories.",
    )
    print(result.final_output)


asyncio.run(main())

For a user's own account, add providerAuthConfigId (provider_auth_config_id in Python) to the provider entry. The ID comes from a setup session. See Let each user connect their own account.

Mistakes to avoid

Generated code often contains these. None of them is current:

  • callbackUri on a setup session. The field is redirectUrl, or redirect_url in Python.
  • metorial.providers.setup_sessions in Python. Use metorial.provider_deployments.setup_sessions.create(...).
  • await on Python resource calls. provider_deployments.create, setup_sessions.create and sessions.create are synchronous. Only metorial.connect() and metorial.wait_for_setup_session() are awaited.
  • import { MetorialAPIError } from 'metorial' in TypeScript. The package does not export it. Use isMetorialSDKError from @metorial/util-endpoint. In Python, MetorialAPIError, AuthenticationError and NotFoundError are exported from metorial. See Error handling.
  • Tool filters of type allow. The types are tool_keys, tool_regex and tool_categories, in a toolFilters list on the provider entry.
  • Relying on pip install metorial to bring a model SDK. Since 2.4.0 it installs none. Add openai, anthropic or your framework yourself.
  • google-generativeai. The Python SDK moved to google-genai in 2.3.3.
  • A synchronous Python client. It was removed in 2.3.0.
  • A publishable key on the server. Sessions and MCP connections need a secret key that starts with metorial_sk_.
  • metorial integrations ... in the CLI. The commands are metorial setup, metorial tools, metorial schema, metorial call and metorial install. Admin tasks use metorial-admin.

Old names and current names

OldCurrent
serverDeployments arrayproviders array
serverDeploymentIdproviderDeploymentId
oauthSessionIdproviderAuthConfigId
metorial.oauth.sessions.create()metorial.providerDeployments.setupSessions.create()
metorial.oauth.waitForCompletion()metorial.providerDeployments.setupSessions.waitForCompletion()
metorial.withProviderSession(...), deprecatedmetorial.connect({ adapter, providers })
Python with_provider_session()await metorial.connect(adapter=..., providers=[...])
Python metorial.adapters module, removed in 2.4.0Adapter functions such as metorial_openai

Check generated code

Type-check TypeScript with npx tsc --noEmit. The old names fail at compile time. Then run the program and list the tool calls Metorial recorded:

metorial-admin sessions tool-calls list \
  --provider-deployment-id $METORIAL_PROVIDER_DEPLOYMENT_ID \
  --limit 5

Next steps