diff --git a/docs/appstore/appuser.md b/docs/appstore/appuser.md new file mode 100644 index 0000000000000000000000000000000000000000..3c1f95e9d13062ef1c9681216bcd5c48d66a33fc --- /dev/null +++ b/docs/appstore/appuser.md @@ -0,0 +1,109 @@ +--- +sidebar_position: 4 +--- + +# 应用用户的登录与注册 + +## 概述 + +:::tip +该接口主要用户实现 AI 应用本身的用户登录注册功能。 +::: + +模力方舟为应用的每一个用户提供了身份认证接口,开发者可以通过该接口来实现用户的身份验证和信息获取。当使用该接口时,系统会为每个用户生成一个用户专属令牌,应用应该使用这个用户专属令牌来调用模型 API。调用模型 API 所产生的费用都会汇集到开发者的应用专属资源包中。 + +这个过程无需最终用户去购买资源包、创建令牌等专业的操作,模力方舟会自动使用开发者的资源包来抵扣用户的模型调用费用。 + +主要包括如下几个接口: + +### 验证码发送接口 + +发送验证码,支持短信或邮箱方式,用于获取应用“用户访问令牌”的验证码。 + +示例代码: + +```python showLineNumbers title="Python" +requests.post("{{API_URL}}/v1/app/auth/vcode", + headers={ + "Authorization": "Bearer {app_access_token}", + "Content-Type": "application/json" + }, + json={ + "appid": "", # 应用的 AppID + "mobile": "", # 用户的手机号码(手机邮箱二选一) + "email": "", # 用户的邮箱地址 + "channel_type": "sms" # 渠道类型,支持 sms 和 email + } +) +``` + +### 用户身份认证接口 + +校验验证码并获取“用户访问令牌”。获取后,用户可使用该凭证下单、查看订阅信息等。如果某手机或者邮箱尚未注册成为应用的用户,则自动注册。 + +示例代码: + +```python showLineNumbers title="Python" +requests.post("https://ai.gitee.com/v1/app/auth/token", + headers={ + "Authorization": "Bearer {app_access_token}", + "Content-Type": "application/json" + }, + json={ + "appid": "", # 应用的 AppID + "channel_type": "sms", + "mobile": "", # 用户的手机号码(手机邮箱二选一) + "email": "", # 用户的邮箱地址 + "code": "" # 验证码 + } +) +``` + +该接口访问用户对应的令牌,可以用该令牌来获取用户信息以及调用模型 API。 + +```json +{ + "access_token": "string" +} +``` + +### 用户信息获取接口 + +获取用户的基本信息,包括用户 ID、手机号、邮箱,以及购买应用的详细信息。 + +```python showLineNumbers title="Python" +requests.get("https://ai.gitee.com/v1/app/auth/userinfo", + headers={ + "Authorization": "Bearer {user_access_token}" + } +) +``` + +返回的结果内容如下: + +```json +{ + "mobile": "string", + "email": "string", + "status": "NORMAL", + "created_at": 1754633185000, + "purchase_status": "ACTIVE", + "pay_plan_ident": "string", + "usage_expired_at": 1754633185000, + "amount": 1, + "balance": 1, + "subscriptions": [ + { + "id": "string", + "pay_plan_ident": "string", + "billing_type": "SUBSCRIPTION", + "billing_multiplier": 1, + "expired_at": 1754633185000, + "status": "ACTIVE", + "effective_at": 1754633185000 + } + ] +} +``` + +有了这个用户信息,接下来就可以使用用户的访问令牌来调用模型 API 以及进行 [付费操作](/docs/appstore/price) 了。 diff --git a/docs/appstore/cost.md b/docs/appstore/cost.md index 7cb81a79931f4f837191bf3de29303c85f0f33e4..e1eca71e430565e5114c76bb234b6956b357af11 100644 --- a/docs/appstore/cost.md +++ b/docs/appstore/cost.md @@ -1,5 +1,5 @@ --- -sidebar_position: 6 +sidebar_position: 7 --- # 收入和成本核算 diff --git a/docs/appstore/create-app.md b/docs/appstore/create-app.md index f3d4029361f36bce1d4dd891ebab967f4c5d29c6..adb453a61963aac9d3c3ca9ee648bbda253c9ffa 100644 --- a/docs/appstore/create-app.md +++ b/docs/appstore/create-app.md @@ -46,8 +46,10 @@ sidebar_position: 3 这个过程无需最终用户去购买资源包、创建令牌等专业的操作,模力方舟会自动使用开发者的资源包来抵扣用户的模型调用费用。 +用户身份认证接口详情请看 [用户身份认证接口文档](/docs/appstore/appuser)。 + ## 使用应用收费接口 为了让开发者在应用中实现收费功能,模力方舟提供了应用收费接口。开发者可以通过该接口来实现应用的收费策略和计费方式。 -详细的收费策略请看下一节。 +详细的收费策略请看 [应用收费策略](/docs/appstore/price)。 diff --git a/docs/appstore/price.md b/docs/appstore/price.md index 010eca85355701aaf205c1acd0fad6e426dc2966..bda17b0055f4d0cee829004bced365efec750e57 100644 --- a/docs/appstore/price.md +++ b/docs/appstore/price.md @@ -1,10 +1,14 @@ --- title: 应用收费策略 -sidebar_position: 4 +sidebar_position: 5 --- # 制定应用收费策略 +:::tip +如果你希望实现应用的商业化,模力方舟提供了灵活的计费接口帮你实现多种收费策略。 +::: + 应用收费策略是指开发者在模力方舟应用市场中为其应用设定的收费方式和价格。通过合理的收费策略,开发者可以实现应用的商业化运营,同时为用户提供优质的服务。 ## 收费策略类型 diff --git a/docs/appstore/publish.md b/docs/appstore/publish.md index a02fef0f664d3a4d9c2f982c7faa4b3a1a9d3d09..823f87d92e9340986ca9b3d0607f49c6b728cc16 100644 --- a/docs/appstore/publish.md +++ b/docs/appstore/publish.md @@ -1,6 +1,6 @@ --- title: 发布到应用市场 -sidebar_position: 5 +sidebar_position: 6 --- # 发布到应用市场