Skip to content

Commit e7cb65b

Browse files
authored
Merge pull request #28 from metorial/feat/cleanup-python-sdk
Feat/cleanup python sdk
2 parents f71f360 + 3d7923b commit e7cb65b

3,265 files changed

Lines changed: 82970 additions & 265869 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@ All notable changes to the Metorial Python SDK will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.4.0] - 2026-07-05
9+
10+
This release contains breaking API and packaging changes.
11+
12+
### Added
13+
14+
- Added full public-API parity with the Node SDK client surface: new top-level endpoint groups `integrations`, `documents`, `stores`, `files`, `skills`, `callbacks`, `magic_mcp`, and `portals`, plus `providers.triggers`. Every group and its nested sub-endpoints (e.g. `skills.templates.items`, `provider_deployments.auth_configs.imports`, `portals.auth.sso_tenants.connections`, `magic_mcp.servers.providers`) is fully typed.
15+
- Added per-provider optional dependency extras so you install only the provider SDKs you use, mirroring the per-provider packages in the JS SDK: `metorial[openai]`, `metorial[anthropic]`, `metorial[google]`, `metorial[mistral]`, the OpenAI-compatible `metorial[openai-compatible]` / `metorial[deepseek]` / `metorial[xai]` / `metorial[togetherai]`, and `metorial[all]` to install every provider.
16+
17+
### Changed
18+
19+
- Provider LLM SDKs (`openai`, `anthropic`, `google-genai`, `mistralai`) are no longer installed by default. The SDK never imports them itself, so its own flows (`connect()`, provider sessions, tool builders) work without any provider SDK present. Install the relevant extra (or `metorial[all]`) if your own code needs a provider client. This is breaking for clean installs that relied on `pip install metorial` transitively providing a provider SDK; in-place upgrades keep any already-installed provider SDK.
20+
- Reworked the endpoint group classes to subclass their generated base endpoint, giving the entire client tree full static type inference (IDE + mypy strict) with no `Any` and no dynamic attribute delegation. Runtime behavior is unchanged.
21+
- Regenerated the packaged Magnetar client against the current enterprise generator output, so the Python endpoint set now matches the Node SDK.
22+
23+
### Removed
24+
25+
- Removed the non-functional `adapters` module and its exports (`ProviderAdapter`, `ChatMessage`, `ChatResponse`, `OpenAIAdapter`, `AnthropicAdapter`, `GoogleAdapter`, `MistralAdapter`, `DeepSeekAdapter`, `TogetherAIAdapter`, `XAIAdapter`, `OpenAICompatibleAdapter`, `create_provider_adapter`, `infer_provider_type`). These imported provider split-packages that were never published and raised `ImportError` when used; the working equivalents live in `metorial.providers`.
26+
- Removed top-level client endpoints that are not part of the public API surface: `provider_categories`, `provider_collections`, `provider_groups`, `provider_listings`, `custom_providers.commits`, `custom_providers.environments`, `sessions.events`, and `sessions.error_groups`.
27+
- Removed the remaining legacy Pulsar generated tree and its internal helpers (`_sdk.py`, `_typed_endpoints.py`, `_generated/pulsar/`, and the unused `ClientCoreMixin` / server-deployment typed dicts).
28+
- Removed unused exported helpers the SDK never used internally: the config layer (`MetorialConfig`, `ProviderConfig`, `load_config_from_env`, `validate_config`, `get_provider_config`), `RawResponse`, `StreamEvent` / `StreamEventType`, and the provider `chat_completions` helpers (`metorial.providers.openai_chat_completions` / `anthropic_chat_completions` and the per-provider `chat_completions` functions/staticmethods). Use `metorial.connect(...)` and the provider sessions' `tools()` / `call_tools()` instead.
29+
30+
### Fixed
31+
32+
- Fixed the Anthropic provider to parse standardized string tool-call arguments with `json.loads` instead of `eval`.
33+
- Fixed the OpenAI Agents and Haystack integrations to execute tools using the original MCP tool name rather than the sanitized display name.
34+
835
## [2.3.3] - 2026-06-12
936

1037
### Changed

README.md

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ The official Python SDK for [Metorial](https://metorial.com). Give your AI agent
1515
pip install metorial
1616
```
1717

18+
| Install | Provides |
19+
| ------------------------------------------- | ------------------------------------------------ |
20+
| `pip install "metorial[openai]"` | OpenAI (`openai`) |
21+
| `pip install "metorial[anthropic]"` | Anthropic (`anthropic`) |
22+
| `pip install "metorial[google]"` | Google Gemini (`google-genai`) |
23+
| `pip install "metorial[mistral]"` | Mistral (`mistralai`) |
24+
| `pip install "metorial[openai-compatible]"` | DeepSeek / Together AI / xAI (OpenAI-compatible) |
25+
| `pip install "metorial[all]"` | Every provider above |
26+
27+
Combine extras as needed, e.g. `pip install "metorial[openai,anthropic]"`. Framework integrations (LangChain, PydanticAI, etc.) pull their own provider clients, so installing the framework is usually all you need.
28+
1829
## Supported LLM Integrations
1930

2031
This SDK formats MCP tools for each LLM provider. Pass the `provider` parameter to get tools in the right format.
@@ -23,7 +34,7 @@ This SDK formats MCP tools for each LLM provider. Pass the `provider` parameter
2334
| ------------- | ----------------------- | --------------------- | ------------------------------------------ |
2435
| OpenAI | `provider="openai"` | `openai` | `gpt-4.1`, `gpt-4o`, `o1`, `o3` |
2536
| Anthropic | `provider="anthropic"` | `anthropic` | `claude-sonnet-4-5`, `claude-opus-4` |
26-
| Google Gemini | `provider="google"` | `google-genai` | `gemini-2.5-pro`, `gemini-2.5-flash` |
37+
| Google Gemini | `provider="google"` | `google-genai` | `gemini-2.5-pro`, `gemini-2.5-flash` |
2738
| Mistral | `provider="mistral"` | `mistralai` | `mistral-large-latest`, `codestral-latest` |
2839
| DeepSeek | `provider="deepseek"` | `openai` (compatible) | `deepseek-chat`, `deepseek-reasoner` |
2940
| Together AI | `provider="togetherai"` | `openai` (compatible) | `Llama-4`, `Qwen-3` |
@@ -33,17 +44,17 @@ This SDK formats MCP tools for each LLM provider. Pass the `provider` parameter
3344

3445
For popular agent frameworks, we provide helper functions that convert tools to the framework's native format:
3546

36-
| Framework | Import | Example |
37-
| ------------- | --------------------------------------------------------------------------- | ------------------------------------------------ |
38-
| AutoGen | `from metorial.integrations.autogen import create_autogen_tools` | [example](./examples/autogen/example.py) |
39-
| CrewAI | `from metorial.integrations.crewai import create_crewai_tools` | [example](./examples/crewai/example.py) |
40-
| Google ADK | `from metorial.integrations.google_adk import create_google_adk_tools` | [example](./examples/google-adk/example.py) |
41-
| LlamaIndex | `from metorial.integrations.llamaindex import create_llamaindex_tools` | [example](./examples/llamaindex/example.py) |
42-
| PydanticAI | `from metorial.integrations.pydantic_ai import create_pydantic_ai_tools` | [example](./examples/pydantic-ai/example.py) |
43-
| LangChain | `from metorial.integrations.langchain import create_langchain_tools` | [example](./examples/langchain/example.py) |
44-
| LangGraph | `from metorial.integrations.langgraph import create_langgraph_tools` | [example](./examples/langgraph/example.py) |
45-
| OpenAI Agents | `from metorial.integrations.openai_agents import create_openai_agent_tools` | [example](./examples/openai-agents/example.py) |
46-
| Haystack | `from metorial.integrations.haystack import create_haystack_tools` | [example](./examples/haystack/example.py) |
47+
| Framework | Import | Example |
48+
| ------------- | --------------------------------------------------------------------------- | ---------------------------------------------- |
49+
| AutoGen | `from metorial.integrations.autogen import create_autogen_tools` | [example](./examples/autogen/example.py) |
50+
| CrewAI | `from metorial.integrations.crewai import create_crewai_tools` | [example](./examples/crewai/example.py) |
51+
| Google ADK | `from metorial.integrations.google_adk import create_google_adk_tools` | [example](./examples/google-adk/example.py) |
52+
| LlamaIndex | `from metorial.integrations.llamaindex import create_llamaindex_tools` | [example](./examples/llamaindex/example.py) |
53+
| PydanticAI | `from metorial.integrations.pydantic_ai import create_pydantic_ai_tools` | [example](./examples/pydantic-ai/example.py) |
54+
| LangChain | `from metorial.integrations.langchain import create_langchain_tools` | [example](./examples/langchain/example.py) |
55+
| LangGraph | `from metorial.integrations.langgraph import create_langgraph_tools` | [example](./examples/langgraph/example.py) |
56+
| OpenAI Agents | `from metorial.integrations.openai_agents import create_openai_agent_tools` | [example](./examples/openai-agents/example.py) |
57+
| Haystack | `from metorial.integrations.haystack import create_haystack_tools` | [example](./examples/haystack/example.py) |
4758

4859
## Quick Start
4960

@@ -268,17 +279,17 @@ credentials = await metorial.provider_deployments.auth_credentials.create(
268279

269280
Check out the `examples/` directory for complete working examples:
270281

271-
| Example | Framework | Description |
272-
|---------|-----------|-------------|
273-
| [`autogen`](examples/autogen/) | AutoGen + OpenAI | AutoGen assistant with tool calls |
274-
| [`crewai`](examples/crewai/) | CrewAI + OpenAI | CrewAI agent with Metorial tools |
275-
| [`google-adk`](examples/google-adk/) | Google ADK + Gemini | Google ADK agent with async tool calls |
276-
| [`pydantic-ai`](examples/pydantic-ai/) | PydanticAI + Anthropic | PydanticAI agent with tool calls |
277-
| [`langchain`](examples/langchain/) | LangChain + Anthropic | LangChain agent with react pattern |
278-
| [`langgraph`](examples/langgraph/) | LangGraph + Anthropic | LangGraph streaming agent |
279-
| [`llamaindex`](examples/llamaindex/) | LlamaIndex + OpenAI | FunctionAgent with tool calls |
280-
| [`openai-agents`](examples/openai-agents/) | OpenAI Agents SDK | OpenAI Agents with tool calls |
281-
| [`haystack`](examples/haystack/) | Haystack + OpenAI | Haystack pipeline with tools |
282+
| Example | Framework | Description |
283+
| ------------------------------------------ | ---------------------- | -------------------------------------- |
284+
| [`autogen`](examples/autogen/) | AutoGen + OpenAI | AutoGen assistant with tool calls |
285+
| [`crewai`](examples/crewai/) | CrewAI + OpenAI | CrewAI agent with Metorial tools |
286+
| [`google-adk`](examples/google-adk/) | Google ADK + Gemini | Google ADK agent with async tool calls |
287+
| [`pydantic-ai`](examples/pydantic-ai/) | PydanticAI + Anthropic | PydanticAI agent with tool calls |
288+
| [`langchain`](examples/langchain/) | LangChain + Anthropic | LangChain agent with react pattern |
289+
| [`langgraph`](examples/langgraph/) | LangGraph + Anthropic | LangGraph streaming agent |
290+
| [`llamaindex`](examples/llamaindex/) | LlamaIndex + OpenAI | FunctionAgent with tool calls |
291+
| [`openai-agents`](examples/openai-agents/) | OpenAI Agents SDK | OpenAI Agents with tool calls |
292+
| [`haystack`](examples/haystack/) | Haystack + OpenAI | Haystack pipeline with tools |
282293

283294
## Provider Examples
284295

pyproject.toml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,36 @@ classifiers = [
2323
keywords = ["metorial", "ai", "llm", "mcp", "openai", "anthropic"]
2424

2525
dependencies = [
26-
# Core HTTP
26+
# Core HTTP + MCP transport (always required)
2727
"aiohttp>=3.8.0",
2828
"aiohttp-sse-client>=0.2.1",
2929
"typing-extensions>=4.0.0",
3030
"httpx>=0.25.0",
3131
"requests>=2.25.0",
3232
"truststore>=0.8.0",
33-
# Provider SDKs (all bundled)
33+
"mcp>=1.0.0",
34+
]
35+
36+
# Provider SDKs are optional: the Metorial SDK itself never imports them, they
37+
# are only needed by your own code that talks to a given LLM provider. Install
38+
# just the ones you use, e.g. `pip install metorial[openai]`, mirroring the
39+
# per-provider packages in the JS SDK. `metorial[all]` installs every provider.
40+
[project.optional-dependencies]
41+
openai = ["openai>=1.0.0"]
42+
anthropic = ["anthropic>=0.69.0"]
43+
google = ["google-genai>=1.0.0"]
44+
mistral = ["mistralai>=1.0.0"]
45+
# OpenAI-compatible providers use the OpenAI client against a custom base URL.
46+
openai-compatible = ["openai>=1.0.0"]
47+
deepseek = ["openai>=1.0.0"]
48+
xai = ["openai>=1.0.0"]
49+
togetherai = ["openai>=1.0.0"]
50+
all = [
3451
"openai>=1.0.0",
3552
"anthropic>=0.69.0",
3653
"google-genai>=1.0.0",
3754
"mistralai>=1.0.0",
38-
# MCP
39-
"mcp>=1.0.0",
4055
]
41-
42-
[project.optional-dependencies]
4356
dev = [
4457
"pytest>=7.0.0",
4558
"pytest-asyncio>=0.20.0",
@@ -87,25 +100,13 @@ ignore_errors = true
87100
disallow_untyped_defs = false
88101
disallow_incomplete_defs = false
89102

90-
# Relax for test code
91-
[[tool.mypy.overrides]]
92-
module = "tests.*"
93-
disallow_untyped_defs = false
94-
disallow_incomplete_defs = false
95-
96103
# Relax for integration modules (depend on optional third-party libraries)
97104
[[tool.mypy.overrides]]
98105
module = "metorial.integrations.*"
99106
ignore_errors = true
100107
disallow_untyped_defs = false
101108
disallow_incomplete_defs = false
102109

103-
# Relax for provider adapters (depend on optional third-party libraries)
104-
[[tool.mypy.overrides]]
105-
module = "metorial.adapters.*"
106-
disallow_untyped_defs = false
107-
disallow_incomplete_defs = false
108-
109110
# Relax for providers (depend on optional third-party libraries)
110111
[[tool.mypy.overrides]]
111112
module = "metorial.providers.*"
@@ -183,4 +184,9 @@ dev = [
183184
"ruff>=0.4.0",
184185
"cblack>=22.6.0",
185186
"pre-commit>=3.5.0",
187+
# All provider SDKs for a complete local dev/type-check environment.
188+
"openai>=1.0.0",
189+
"anthropic>=0.69.0",
190+
"google-genai>=1.0.0",
191+
"mistralai>=1.0.0",
186192
]

src/metorial/__init__.py

Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,27 @@
88
import logging as _logging
99

1010
from ._client import Metorial, ProviderSession
11-
12-
# Configuration
13-
from ._config import (
14-
MetorialConfig,
15-
ProviderConfig,
16-
get_provider_config,
17-
load_config_from_env,
18-
validate_config,
19-
)
2011
from ._magnetar_sdk import (
12+
MagnetarCallbacksGroup,
2113
MagnetarCustomProvidersGroup,
14+
MagnetarDocumentsGroup,
15+
MagnetarFilesGroup,
16+
MagnetarIntegrationsGroup,
17+
MagnetarMagicMcpGroup,
18+
MagnetarPortalsGroup,
2219
MagnetarProviderDeploymentsGroup,
2320
MagnetarProvidersGroup,
2421
MagnetarSDK,
2522
MagnetarSessionsGroup,
2623
MagnetarSessionTemplatesGroup,
24+
MagnetarSkillsGroup,
25+
MagnetarStoresGroup,
2726
create_magnetar_sdk,
2827
)
29-
30-
# Raw response wrapper
31-
from ._raw_response import RawResponse
32-
from ._sdk import SDKConfig
28+
from ._sdk_shared import SDKConfig
3329

3430
# Session management
3531
from ._session import MetorialSession, SessionFactory
36-
37-
# Streaming types
38-
from ._streaming import StreamEvent, StreamEventType
3932
from ._tool_adapters import (
4033
MetorialTool,
4134
OpenAITool,
@@ -51,23 +44,6 @@
5144
# Types
5245
from ._types import DictAttributeAccess, MetorialClient
5346
from ._version import __version__
54-
55-
# Adapters
56-
from .adapters import (
57-
AnthropicAdapter,
58-
ChatMessage,
59-
ChatResponse,
60-
DeepSeekAdapter,
61-
GoogleAdapter,
62-
MistralAdapter,
63-
OpenAIAdapter,
64-
OpenAICompatibleAdapter,
65-
ProviderAdapter,
66-
TogetherAIAdapter,
67-
XAIAdapter,
68-
create_provider_adapter,
69-
infer_provider_type,
70-
)
7147
from .connectors import (
7248
ConnectedSession,
7349
MetorialAdapter,
@@ -162,12 +138,6 @@ def _configure_sdk_logging() -> None:
162138
# Core clients
163139
"Metorial",
164140
"ProviderSession",
165-
# Configuration
166-
"MetorialConfig",
167-
"ProviderConfig",
168-
"load_config_from_env",
169-
"get_provider_config",
170-
"validate_config",
171141
# Session
172142
"MetorialSession",
173143
"SessionFactory",
@@ -198,11 +168,6 @@ def _configure_sdk_logging() -> None:
198168
"MetorialTimeoutError",
199169
"MetorialDuplicateToolError",
200170
"is_metorial_sdk_error",
201-
# Raw response
202-
"RawResponse",
203-
# Streaming
204-
"StreamEvent",
205-
"StreamEventType",
206171
# Types
207172
"DictAttributeAccess",
208173
"MetorialClient",
@@ -227,20 +192,6 @@ def _configure_sdk_logging() -> None:
227192
"metorial_llamaindex",
228193
"metorial_openai_agents",
229194
"metorial_haystack",
230-
# Adapters
231-
"ProviderAdapter",
232-
"ChatMessage",
233-
"ChatResponse",
234-
"OpenAIAdapter",
235-
"AnthropicAdapter",
236-
"GoogleAdapter",
237-
"MistralAdapter",
238-
"DeepSeekAdapter",
239-
"TogetherAIAdapter",
240-
"XAIAdapter",
241-
"OpenAICompatibleAdapter",
242-
"infer_provider_type",
243-
"create_provider_adapter",
244195
# Magnetar SDK
245196
"SDKConfig",
246197
"MagnetarSDK",
@@ -249,6 +200,14 @@ def _configure_sdk_logging() -> None:
249200
"MagnetarSessionsGroup",
250201
"MagnetarSessionTemplatesGroup",
251202
"MagnetarCustomProvidersGroup",
203+
"MagnetarIntegrationsGroup",
204+
"MagnetarDocumentsGroup",
205+
"MagnetarStoresGroup",
206+
"MagnetarFilesGroup",
207+
"MagnetarSkillsGroup",
208+
"MagnetarCallbacksGroup",
209+
"MagnetarMagicMcpGroup",
210+
"MagnetarPortalsGroup",
252211
"create_magnetar_sdk",
253212
# MCP
254213
"MetorialMagnetarMcpSession",

0 commit comments

Comments
 (0)