接口规范#
开发者可直接使用 Anthropic 官方 Python 和 Node.js SDK 接入,只需要将官方 API 服务的基础 URL 和官方 API Key 更换为 MetaChat Claude API 服务的基础 URL 和 API Key 即可:api.anthropic.com -> llm-api.mmchat.xyz
claude-3-5-haiku-20241022
接口鉴权#
调用 MetaChat Claude API 时,需 API Key 进行鉴权(API Key 获取方法请参考 概述 文档说明。与 Claude 官方接口鉴权规范相同,所有 API 请求都应在 HTTP Header 中包含 API Key,如下所示:调用样例#
安全提示:请不要直接将 API Key 硬编码在代码中,上述样例中均采用了环境变量(METACHAT_API_KEY)的方式保存 API Key,并分别在 Python 和 Node.js 代码中引用。
OpenAI 兼容接口#
MetaChat Claude API 支持 OpenAI 兼容接口定义,开发者可以直接利用 OpenAI Python 或 Node.js SDK 调用 Claude API,只需要将官方 API 服务的基础 URL 更换为 MetaChat API 服务的基础 URL 和 API Key,在 model 参数中填写 Claude 模型即可: