Claude Platform Docs

Go API 參考文件

建立訊息
client.Messages.New(ctx, params) (*Message, error)
POST/v1/messages

傳送包含文字和/或圖片內容的結構化輸入訊息清單,模型將產生對話中的下一則訊息。

計算訊息中的 Token 數
client.Messages.CountTokens(ctx, params) (*MessageTokensCount, error)
POST/v1/messages/count_tokens

計算訊息中的 Token 數量。

列出模型
client.Models.List(ctx, params) (*Page[ModelInfo], error)
GET/v1/models

列出可用的模型。

取得模型
client.Models.Get(ctx, modelID, query) (*ModelInfo, error)
GET/v1/models/{model_id}

取得特定模型。

上傳檔案
client.Files.Upload(ctx, params) (*FileMetadata, error)
POST/v1/files
列出檔案
client.Files.List(ctx, params) (*PageCursor[FileMetadata], error)
GET/v1/files
下載檔案
client.Files.Download(ctx, fileID, query) (*Response, error)
GET/v1/files/{file_id}/content
取得檔案中繼資料
client.Files.GetMetadata(ctx, fileID, query) (*FileMetadata, error)
GET/v1/files/{file_id}
刪除檔案
client.Files.Delete(ctx, fileID, body) (*DeletedFile, error)
DELETE/v1/files/{file_id}
建立技能
client.Skills.New(ctx, params) (*Skill, error)
POST/v1/skills
列出技能
client.Skills.List(ctx, params) (*PageCursor[Skill], error)
GET/v1/skills
取得技能
client.Skills.Get(ctx, skillID, query) (*Skill, error)
GET/v1/skills/{skill_id}
刪除技能
client.Skills.Delete(ctx, skillID, body) (*DeletedSkill, error)
DELETE/v1/skills/{skill_id}

使用者設定檔

註冊您的平台所服務的終端客戶,讓每個請求都能指明其服務對象。若要開始使用,請參閱使用者設定檔指南。

建立使用者設定檔
client.UserProfiles.New(ctx, params) (*UserProfile, error)
POST/v1/user_profiles

註冊您的一位終端客戶,並取得 ID,以便在您代其發出的請求中傳送。

列出使用者設定檔
client.UserProfiles.List(ctx, params) (*PageCursor[UserProfile], error)
GET/v1/user_profiles

列出您組織中的使用者設定檔,預設以最新的優先排列。

取得使用者設定檔
client.UserProfiles.Get(ctx, userProfileID, query) (*UserProfile, error)
GET/v1/user_profiles/{user_profile_id}

依 ID 取得使用者設定檔,以檢查為其儲存的詳細資訊。

更新使用者設定檔
client.UserProfiles.Update(ctx, userProfileID, params) (*UserProfile, error)
POST/v1/user_profiles/{user_profile_id}

變更使用者設定檔的詳細資訊,您未傳送的欄位將維持不變。

刪除使用者設定檔
client.UserProfiles.Delete(ctx, userProfileID, body) (*DeletedUserProfile, error)
DELETE/v1/user_profiles/{user_profile_id}

刪除使用者設定檔,例如在終端客戶關閉其帳戶時。

取得目前組織
client.Organization.Get(ctx) (*OrganizationInfo, error)
GET/v1/organizations/me

擷取與已驗證 API 金鑰相關聯之組織的資訊。