Claude Platform Docs

Python API 参考

创建消息
messages.create(**kwargs) -> Message
POST/v1/messages

发送包含文本和/或图像内容的结构化输入消息列表,模型将生成对话中的下一条消息。

计算消息中的令牌数
messages.count_tokens(**kwargs) -> MessageTokensCount
POST/v1/messages/count_tokens

计算消息中的令牌数量。

列出模型
models.list(**kwargs) -> SyncPage[ModelInfo]
GET/v1/models

列出可用模型。

获取模型
models.retrieve(model_id, **kwargs) -> ModelInfo
GET/v1/models/{model_id}

获取特定模型。

上传文件
files.upload(**kwargs) -> FileMetadata
POST/v1/files
列出文件
files.list(**kwargs) -> SyncPageCursor[FileMetadata]
GET/v1/files
下载文件
files.download(file_id, **kwargs) -> BinaryResponseContent
GET/v1/files/{file_id}/content
获取文件元数据
files.retrieve_metadata(file_id, **kwargs) -> FileMetadata
GET/v1/files/{file_id}
删除文件
files.delete(file_id, **kwargs) -> DeletedFile
DELETE/v1/files/{file_id}
创建技能
skills.create(**kwargs) -> Skill
POST/v1/skills
列出技能
skills.list(**kwargs) -> SyncPageCursor[Skill]
GET/v1/skills
获取技能
skills.retrieve(skill_id, **kwargs) -> Skill
GET/v1/skills/{skill_id}
删除技能
skills.delete(skill_id, **kwargs) -> DeletedSkill
DELETE/v1/skills/{skill_id}

用户配置文件

Register the end customers that your platform serves, so each request can name who it's for. To get started, see the User profiles guide.

创建用户配置文件
user_profiles.create(**kwargs) -> UserProfile
POST/v1/user_profiles

Register one of your end customers and get the ID to send on the requests you make for them.

列出用户配置文件
user_profiles.list(**kwargs) -> SyncPageCursor[UserProfile]
GET/v1/user_profiles

List the user profiles in your organization, newest first by default.

获取用户配置文件
user_profiles.retrieve(user_profile_id, **kwargs) -> UserProfile
GET/v1/user_profiles/{user_profile_id}

Get a user profile by ID to check the details stored for it.

更新用户配置文件
user_profiles.update(user_profile_id, **kwargs) -> UserProfile
POST/v1/user_profiles/{user_profile_id}

Change the details of a user profile, leaving the fields that you don't send as they are.

删除用户配置文件
user_profiles.delete(user_profile_id, **kwargs) -> DeletedUserProfile
DELETE/v1/user_profiles/{user_profile_id}

Delete a user profile, for example when the end customer closes their account.

获取当前组织
organization.retrieve() -> OrganizationInfo
GET/v1/organizations/me

检索与经过身份验证的 API 密钥关联的组织的信息。