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
- A secret API key in
METORIAL_API_KEY - A provider deployment ID in
METORIAL_PROVIDER_DEPLOYMENT_ID. Create one withmetorial-admin providers deployments create --provider-id metorial-search --name "Metorial Search".
Current packages
| Package | Version on 2026-11-22 | Use |
|---|---|---|
metorial (npm) | 3.3.6 | TypeScript and JavaScript SDK |
@metorial/ai-sdk | 3.0.9 | Adapter for the Vercel AI SDK |
@metorial/openai, @metorial/anthropic, @metorial/google | 3.0.11 | Adapters for the model SDKs |
@metorial/langchain | 3.0.9 | Adapter for LangChain and LangGraph |
metorial (PyPI) | 2.7.0, Python 3.10 or later | Python SDK with every adapter built in |
@metorial/cli, @metorial/admin | 0.1.9 | The 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.
The recommended program
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:
callbackUrion a setup session. The field isredirectUrl, orredirect_urlin Python.metorial.providers.setup_sessionsin Python. Usemetorial.provider_deployments.setup_sessions.create(...).awaiton Python resource calls.provider_deployments.create,setup_sessions.createandsessions.createare synchronous. Onlymetorial.connect()andmetorial.wait_for_setup_session()are awaited.import { MetorialAPIError } from 'metorial'in TypeScript. The package does not export it. UseisMetorialSDKErrorfrom@metorial/util-endpoint. In Python,MetorialAPIError,AuthenticationErrorandNotFoundErrorare exported frommetorial. See Error handling.- Tool filters of type
allow. The types aretool_keys,tool_regexandtool_categories, in atoolFilterslist on the provider entry. - Relying on
pip install metorialto bring a model SDK. Since 2.4.0 it installs none. Addopenai,anthropicor your framework yourself. google-generativeai. The Python SDK moved togoogle-genaiin 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 aremetorial setup,metorial tools,metorial schema,metorial callandmetorial install. Admin tasks usemetorial-admin.
Old names and current names
| Old | Current |
|---|---|
serverDeployments array | providers array |
serverDeploymentId | providerDeploymentId |
oauthSessionId | providerAuthConfigId |
metorial.oauth.sessions.create() | metorial.providerDeployments.setupSessions.create() |
metorial.oauth.waitForCompletion() | metorial.providerDeployments.setupSessions.waitForCompletion() |
metorial.withProviderSession(...), deprecated | metorial.connect({ adapter, providers }) |
Python with_provider_session() | await metorial.connect(adapter=..., providers=[...]) |
Python metorial.adapters module, removed in 2.4.0 | Adapter 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:
Next steps
- Choose between the SDK, the REST API and plain MCP: which path fits your stack
- Framework guides: one complete program per framework
- Use the docs in your AI client: give a coding agent these docs over MCP