Skip to main content

Metis Python SDK

Metis 应用后端 SDK,用于读取统一应用身份、可信请求上下文、声明的 Web/Service 依赖,以及模型和对象存储配置。

安装

python -m pip install metis-platform-sdk
from metis_sdk import from_env

client = from_env()
for dependency in client.list_dependencies():
    print(dependency["app_id"])
embedding = client.model("embedding.0")
rerank = client.model("rerank.0")
print(embedding["model"], rerank["model"])

model() 支持 llm.N、embedding.N 和 rerank.N 三类 slot,并返回对应的网关地址、模型别名、API key 及类型专属参数。SDK 不创建厂商客户端。

runtime_config() 返回当前 service 的模型展示名称、图标、能力、上下文限制、状态和 revision,不返回 API key 或供应商凭据:

config = client.runtime_config()
for slot, model in config.models.items():
    print(slot, model.display_name, model.busy_level)

Runtime Config 中原始 protobuf 类型为 int64 或 uint64 的字段(例如 revision、installation_id、context_window 和 icon_file_id)在 protojson 中使用十进制字符串,Python SDK 也保持为 str。SDK 不把这些值转换为整数或根据内容猜测类型;需要计算时由应用显式调用 int(value)。int32/uint32 和有限浮点字段仍按数字处理。

模型 slot API key 始终必填,请显式选择最终用户归因:

from metis_sdk import platform_identity_from_request, with_external_user, without_user_attribution

request = model.new_request("POST", "/v1/chat/completions", platform_identity_from_request(incoming_request), body)
request = model.new_request("POST", "/v1/chat/completions", with_external_user("customer-42"), body)
request = model.new_request("POST", "/v1/embeddings", without_user_attribution(), body)

优先从平台保护入口的可信请求头构造平台用户归因。外部用户归因只适用于应用已自行认证的用户;无法对应到个人的后台任务才归入其他用户。浏览器端不得持有模型 slot API key。

运行环境必须提供 METIS_PLATFORM_ENDPOINT、METIS_APP_ID 和 METIS_APP_TOKEN。本地测试可以向 Client 显式传入配置。SDK 不创建厂商模型/存储客户端,也不隐藏重试。

依赖和 endpoint 返回字段会转换为 Python 风格:依赖使用 app_id、requested_version、 resolved_version、package_sha256、direct、available、resolution_error、app_type 和 web_base_path;应用应在使用可选依赖前检查 available。

开发

python -m pytest
python -m build

许可证

Apache-2.0,见 LICENSE。

Metadata

Release files for metis-platform-sdk 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metis-platform-sdk 0.4.2
File Size Uploaded Provenance
metis_platform_sdk-0.4.2.tar.gz 15.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for metis-platform-sdk 0.4.2
File Interpreter ABI Platform
metis_platform_sdk-0.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 kB

Release files / metis_platform_sdk-0.4.2.tar.gz

Download URL metis_platform_sdk-0.4.2.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
121800b3765479223f42f170a0edca26c075c0d70ba7e6e4b8339c00f99aef67
BLAKE2b-256 checksum
How to use checksums
4206db65bddfd82de9439a2f5ca29653d11385759f5a19425a79b599eaf69303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / metis_platform_sdk-0.4.2-py3-none-any.whl

Download URL metis_platform_sdk-0.4.2-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75bfd1b44a4731154564c3b4f0fd1dba9cb981cc289e49104afd590a6b1f71d1
BLAKE2b-256 checksum
How to use checksums
9752231b0c366318ac0e7226e79d0934998be4519caecc5cee526b9c35383586
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for metis-platform-sdk 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for metis_platform_sdk-0.4.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page