npm install nuwaai-sdk
import { NuwaAISDK } from 'nuwaai-sdk';
const sdk=new NuwaAISDK()
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaAIConfig;
NuwaAIConfig config = NuwaAIConfig.builder()
.apiKey("sk-xxxx")
.build();
NuwaAIClient.init(config);
const nuwa = require('../../utils/nuwa-sdk.js');
const sdk = nuwa.createClient({ secretKey: 'sk-xxxx' });
接口调用流程:
- 第一步:到平台申请API Key
- 第二步:调用鉴权接口,通过API Key获取Token
- 第三步:调用业务接口,请求头带上token
Base URL:
所有接口默认采用以下 Header:
| Header | Value |
|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
{
"code": 0,
"msg": "success",
"data": Object
}
- code:0 表示成功
- message:错误或提示信息
- data:实际返回内容
POST /web/apiKey/auth
const res = await sdk.authByApiKey("sk-xxxx");
console.log(res.data);
import NuwaSDK
NuwaAuthManager.getAccessTokenWithAPIKey("sk-xxxx") { accessToken, error in
if let error = error {
print("获取令牌失败: \(error.localizedDescription)")
return
}
if let accessToken = accessToken {
print("获取令牌成功: \(accessToken)")
}
}
#import <NuwaSDK/NuwaSDK.h>
[NuwaAuthManager getAccessTokenWithAPIKey:@"sk-xxxx" completion:^(NSString * _Nullable accessToken, NSError * _Nullable error) {
if (error) {
NSLog(@"获取令牌失败: %@", error.localizedDescription);
return;
}
if (accessToken) {
NSLog(@"获取令牌成功: %@", accessToken);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().authenticate(new NuwaCallback<String>() {
@Override
public void onSuccess(String token) {
}
@Override
public void onFailure(int code, String message) { }
});
const nuwa = require('../../utils/nuwa-sdk.js');
const sdk = nuwa.createClient({ secretKey: 'sk-xxxx' });
const token = await sdk.auth();
console.log(token);
{
"code": 0,
"msg": null,
"data": "MnTjgFHRfslJov-PG9yNdKtGaxPicW06VKCRCt5-zuAh_YA0ECkp9cbFCR8kuK50EgSPFjtabTkAtR-1fNFLUoa-G7o3301t4zIem82yn2Sj5iglV-GDU3OA7pwaZff_"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| secretKey | String | 是 | API key |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | token |
POST /web/web-file/upload
const uploadRes = await sdk.uploadFile(file);
console.log(uploadRes.data.url);
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
let fileURL = URL(fileURLWithPath: "/path/to/local.jpg")
apiClient.uploadFile(fileURL) { result, error in
if let error = error {
print("上传失败: \(error.localizedDescription)")
return
}
if let result = result, let url = result["url"] as? String {
print("上传成功,文件URL: \(url)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
NSURL *fileURL = [NSURL fileURLWithPath:@"/path/to/local.jpg"];
[apiClient uploadFile:fileURL completion:^(NSDictionary * _Nullable result, NSError * _Nullable error) {
if (error) {
NSLog(@"上传失败: %@", error.localizedDescription);
return;
}
if (result) {
NSString *url = result[@"url"];
if (url) {
NSLog(@"上传成功,文件URL: %@", url);
}
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.FileUploadResult;
import java.io.File;
File file = new File("/path/to/local.jpg");
NuwaAIClient.getInstance().getFileManager().uploadFile(file, new NuwaCallback<FileUploadResult>() {
@Override
public void onSuccess(FileUploadResult data) {
String url = data.getUrl();
}
@Override
public void onFailure(int code, String message) { }
});
const res = await sdk.uploadFile(filePath);
console.log(res.url);
{
"code": 0,
"msg": null,
"data": {
"bucketName": "nuwa",
"fileName": "78/202512/20251202/5c0b16e1c89d4ff9ae9b93f775a722f6.jpeg",
"url": "/nuwa/78/202512/20251202/5c0b16e1c89d4ff9ae9b93f775a722f6.jpeg"
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| file | MultipartFile | 是 | 文件 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| bucketName | String | 桶名 |
| fileName | String | oss中的文件名 |
| url | String | oss中的路径 |
DELETE /web/web-file/deleteFile
await sdk.deleteFile("/nuwa/xx/xx.pptx");
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.deleteFile("/nuwa/xx/xx.pptx") { success, error in
if let error = error {
print("删除失败: \(error.localizedDescription)")
return
}
if success {
print("删除成功")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient deleteFile:@"/nuwa/xx/xx.pptx" completion:^(BOOL success, NSError * _Nullable error) {
if (error) {
NSLog(@"删除失败: %@", error.localizedDescription);
return;
}
if (success) {
NSLog(@"删除成功");
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getFileManager().deleteFile("/nuwa/xx/xx.pptx", new NuwaCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.deleteFile('/nuwa/xx/xx.pptx');
{
"code": 0,
"msg": null,
"data": true
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| filePath | String | 是 | oss中的文件路径 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Boolean | true : 成功,false:失败 |
GET /web/document/getDownPreSignedUrl
const previewRes = await sdk.getDownPreSignedUrl("134/figure/demo.mp4");
console.log(previewRes.data);
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.getPreviewURLForFilename("134/figure/demo.mp4") { previewURL, error in
if let error = error {
print("获取预览地址失败: \(error.localizedDescription)")
return
}
if let previewURL = previewURL {
print("预览地址: \(previewURL)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient getPreviewURLForFilename:@"134/figure/demo.mp4" completion:^(NSString * _Nullable previewURL, NSError * _Nullable error) {
if (error) {
NSLog(@"获取预览地址失败: %@", error.localizedDescription);
return;
}
if (previewURL) {
NSLog(@"预览地址: %@", previewURL);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getFileManager().getPreSignedUrl("134/figure/demo.mp4", new NuwaCallback<String>() {
@Override
public void onSuccess(String url) { }
@Override
public void onFailure(int code, String message) { }
});
const url = await sdk.getDownPreSignedUrl('134/figure/demo.mp4');
console.log(url);
{
"code": 0,
"msg": null,
"data": "https://nuwa-ai.oss-cn-shenzhen.aliyuncs.com/134/figure/1947499417004638210/be367e3322de4b0eb857aaa62ddd3e46.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20251202T025318Z&X-Amz-SignedHeaders=host&X-Amz-Expires=518399&X-Amz-Credential=YHenriLQRiAqWFbmnZgQ%2F20251202%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=93e949dd325710726103601e661b9bb8b517abcc830fc783388fcd067ecee586"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| filename | String | 是 | oss中的文件名 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | 文件预览地址 |
GET /web/web-file/download
const resp = await sdk.downloadFile("/nuwa/xx/demo.pptx");
const blob = await resp.blob();
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.downloadFile("/nuwa/xx/demo.pptx") { data, error in
if let error = error {
print("下载失败: \(error.localizedDescription)")
return
}
if let data = data {
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let fileURL = documentsDirectory.appendingPathComponent("demo.pptx")
do {
try data.write(to: fileURL)
print("文件保存成功: \(fileURL.path)")
} catch {
print("保存文件失败: \(error.localizedDescription)")
}
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient downloadFile:@"/nuwa/xx/demo.pptx" completion:^(NSData * _Nullable data, NSError * _Nullable error) {
if (error) {
NSLog(@"下载失败: %@", error.localizedDescription);
return;
}
if (data) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"demo.pptx"];
BOOL success = [data writeToFile:filePath atomically:YES];
if (success) {
NSLog(@"文件保存成功: %@", filePath);
} else {
NSLog(@"保存文件失败");
}
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import okhttp3.ResponseBody;
NuwaAIClient.getInstance().getFileManager().downloadFile("/nuwa/xx/demo.pptx", new NuwaCallback<ResponseBody>() {
@Override
public void onSuccess(ResponseBody body) {
}
@Override
public void onFailure(int code, String message) { }
});
const tempFilePath = await sdk.downloadFile('/nuwa/xx/demo.pptx');
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| url | String | 是 | oss中的文件地址 |
POST /web/model/submitTask
await sdk.textToImage({
forwardPrompt: "生成一张在海边散步的美女图片",
bizId: 1995841869673639938,
from: "1",
aspectRatio: "16:9",
model: "doubao-seedream-4-5-251128"
});
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.textToImageWithForwardPrompt("生成一张在海边散步的美女图片",
bizId: "1995841869673639938",
from: "1",
aspectRatio: "16:9",
model: "doubao-seedream-4-5-251128") { taskId, error in
if let error = error {
print("文生图失败: \(error.localizedDescription)")
return
}
if let taskId = taskId {
print("文生图任务已提交,任务ID: \(taskId)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient textToImageWithForwardPrompt:@"生成一张在海边散步的美女图片"
bizId:@"1995841869673639938"
from:@"1"
aspectRatio:@"16:9"
model:@"doubao-seedream-4-5-251128"
completion:^(NSString * _Nullable taskId, NSError * _Nullable error) {
if (error) {
NSLog(@"文生图失败: %@", error.localizedDescription);
return;
}
if (taskId) {
NSLog(@"文生图任务已提交,任务ID: %@", taskId);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getModelManager().text2Image(
"生成一张在海边散步的美女图片",
1995841869673639938L,
"1",
"doubao-seedream-4-5-251128",
"16:9",
new NuwaCallback<String>() {
@Override
public void onSuccess(String requestId) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.submitTask({
type: 'text2img',
forwardPrompt: '生成一张在海边散步的美女图片',
bizId: 1995841869673639938,
from: '1',
aspectRatio: '16:9',
model: 'doubao-seedream-4-5-251128'
});
{
"code": 0,
"msg": null,
"data": "0be340e8bfd4405fab420a02ac3150d1"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| type | String | 是 | 生成类型(img2img:图生图,text2img:文生图,img2video:图生视频) |
| forwardPrompt | String | 是 | 正向提示词 |
| bizId | Long | 是 | 形象或才艺Id |
| from | String | 是 | 来源(1:形象美化,2:才艺美化,3:创建数字人,4:生成形象动作视频,5:生成才艺动作视频) |
| model | String | 是 | 模型Id(文生图可选项:gemini-3-pro-image-preview,gemini-3.1-flash-image-preview,doubao-seedream-4-0-250828,doubao-seedream-4-5-251128,doubao-seedream-5-0-260128) |
| aspectRatio | String | 否 | 生成图片的宽高比(可选:16:9,9:16,默认:16:9) |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | 请求Id |
POST /web/model/submitTask
await sdk.imageToImage({
forwardPrompt: "请保持风格生成新图",
bizId: 1995841869673639938,
from: "1",
path: "/nuwa/xx/ref.jpg"
});
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.imageToImageWithForwardPrompt("请保持风格生成新图",
imageURL: "/nuwa/xx/ref.jpg",
bizId: "1995841869673639938",
from: "1",
aspectRatio: nil,
model: "doubao-seedream-4-5-251128") { taskId, error in
if let error = error {
print("图生图失败: \(error.localizedDescription)")
return
}
if let taskId = taskId {
print("图生图任务已提交,任务ID: \(taskId)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient imageToImageWithForwardPrompt:@"请保持风格生成新图"
imageURL:@"/nuwa/xx/ref.jpg"
bizId:@"1995841869673639938"
from:@"1"
aspectRatio:nil
model:@"doubao-seedream-4-5-251128"
completion:^(NSString * _Nullable taskId, NSError * _Nullable error) {
if (error) {
NSLog(@"图生图失败: %@", error.localizedDescription);
return;
}
if (taskId) {
NSLog(@"图生图任务已提交,任务ID: %@", taskId);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getModelManager().img2Image(
"请保持风格生成新图",
1995841869673639938L,
"1",
"doubao-seedream-4-5-251128",
null,
"/nuwa/xx/ref.jpg",
new NuwaCallback<String>() {
@Override
public void onSuccess(String requestId) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.submitTask({
type: 'img2img',
forwardPrompt: '请保持风格生成新图',
bizId: 1995841869673639938,
from: '1',
model: 'doubao-seedream-4-5-251128',
path: '/nuwa/xx/ref.jpg'
});
{
"code": 0,
"msg": null,
"data": "0be340e8bfd4405fab420a02ac3150d1"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| type | String | 是 | 生成类型(img2img:图生图,text2img:文生图,img2video:图生视频) |
| forwardPrompt | String | 是 | 正向提示词 |
| bizId | Long | 是 | 形象或才艺Id |
| from | String | 是 | 来源(1:形象美化,2:才艺美化,3:创建数字人,4:生成形象动作视频,5:生成才艺动作视频) |
| model | String | 是 | 模型Id(图生图可选项:gemini-3-pro-image-preview,gemini-3.1-flash-image-preview,doubao-seedream-4-0-250828,doubao-seedream-4-5-251128,doubao-seedream-5-0-260128) |
| aspectRatio | String | 否 | 生成图片的宽高比(可选:16:9,9:16,默认:16:9) |
| path | String | 是 | Oss中参考图片地址 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | 请求Id |
GET /api/order/detail?id=557899
await sdk.imageToVideo({
forwardPrompt: "人物轻微走动",
bizId: 1995841869673639938,
from: "1",
videoTime: 5,
path: "/nuwa/xx/ref.jpg"
});
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.imageToVideoWithForwardPrompt("人物轻微走动",
imageURL: "/nuwa/xx/ref.jpg",
bizId: "1995841869673639938",
from: "1",
videoTime: 5) { taskId, error in
if let error = error {
print("图生视频失败: \(error.localizedDescription)")
return
}
if let taskId = taskId {
print("图生视频任务已提交,任务ID: \(taskId)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient imageToVideoWithForwardPrompt:@"人物轻微走动"
imageURL:@"/nuwa/xx/ref.jpg"
bizId:@"1995841869673639938"
from:@"1"
videoTime:5
completion:^(NSString * _Nullable taskId, NSError * _Nullable error) {
if (error) {
NSLog(@"图生视频失败: %@", error.localizedDescription);
return;
}
if (taskId) {
NSLog(@"图生视频任务已提交,任务ID: %@", taskId);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getModelManager().img2Video(
"人物轻微走动",
1995841869673639938L,
"1",
null,
null,
"/nuwa/xx/ref.jpg",
5,
new NuwaCallback<String>() {
@Override
public void onSuccess(String requestId) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.submitTask({
type: 'img2video',
forwardPrompt: '人物轻微走动',
bizId: 1995841869673639938,
from: '1',
videoTime: 5,
path: '/nuwa/xx/ref.jpg'
});
{
"code": 0,
"msg": null,
"data": "0be340e8bfd4405fab420a02ac3150d1"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| type | String | 是 | 生成类型(img2img:图生图,text2img:文生图,img2video:图生视频) |
| forwardPrompt | String | 是 | 正向提示词 |
| bizId | Long | 是 | 形象或才艺Id |
| from | String | 是 | 来源(1:形象美化,2:才艺美化,3:创建数字人,4:生成形象动作视频,5:生成才艺动作视频) |
| videoTime | String | 是 | 视频时长(单位:秒),可选范围[4,10] |
| path | String | 是 | Oss中参考图片地址 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | 请求Id |
POST /web/model/queryTask
await sdk.queryModelTask("requestId", 0);
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.queryTaskWithRequestId("requestId", lastReq: 0) { result, error in
if let error = error {
print("查询任务失败: \(error.localizedDescription)")
return
}
if let result = result {
print("查询任务成功: \(result)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient queryTaskWithRequestId:@"requestId" lastReq:0 completion:^(NSDictionary * _Nullable result, NSError * _Nullable error) {
if (error) {
NSLog(@"查询任务失败: %@", error.localizedDescription);
return;
}
if (result) {
NSLog(@"查询任务成功: %@", result);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.QueryTaskRequest;
import com.nuwaai.sdk.model.TaskResult;
QueryTaskRequest req = new QueryTaskRequest("requestId", 0);
NuwaAIClient.getInstance().getModelManager().queryTask(req, new NuwaCallback<TaskResult>() {
@Override
public void onSuccess(TaskResult data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.queryTask({ requestId: 'requestId', lastReq: 0 });
{
"code": 0,
"msg": null,
"data": {
"status": "done",
"data": {
"requestId": "6fa929b620b74dbabe90bade8d967f7a",
"thumbnailPath": "/pub-nuwa/78/figure/1995841869673639938/a5e9d52675be4a0da036a8093e3ab1d0.jpg",
"scenePath": "/nuwa/78/figure/1995841869673639938/58eafbb780964614bc5d7b4761211517.jpg",
"watermarkUrl": "/nuwa/78/figure/1995841869673639938/81ab006fee864635b63b35499216f383.jpg",
"videoPath": null,
"userId": "78",
"from": "1"
}
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| requestId | String | 是 | 请求Id |
| lastReq | Integer | 是 | 是否最后一次请求(0:否,1:是) |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| 数据对象属性 | | |
| status | String | 处理状态(running:处理中,done:处理完成) |
| data | Object | 处理结果数据 |
| requestId | String | 请求Id |
| userId | Long | 用户Id |
| from | String | 来源(1:形象美化,2:才艺美化,3:创建数字人,4:生成形象动作视频,5:生成才艺动作视频) |
| videoPath | String | 生成的视频路径 |
| scenePath | String | 生成的图片路径 |
| thumbnailPath | String | 生成的缩略图路径 |
| watermarkUrl | String | 生成的带水印的图片路径 |
POST /webhp/humanAgent/voiceSet
await sdk.voiceSet(file, "音频文案");
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
let audioURL = URL(fileURLWithPath: "/path/to/audio.wav")
apiClient.createVoiceModel(audioURL, text: "音频文案") { models, error in
if let error = error {
print("创作声音模型失败: \(error.localizedDescription)")
return
}
if let models = models {
print("创作声音模型成功: \(models)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
NSURL *audioURL = [NSURL fileURLWithPath:@"/path/to/audio.wav"];
[apiClient createVoiceModel:audioURL text:@"音频文案" completion:^(NSArray * _Nullable models, NSError * _Nullable error) {
if (error) {
NSLog(@"创作声音模型失败: %@", error.localizedDescription);
return;
}
if (models) {
NSLog(@"创作声音模型成功: %@", models);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.VoiceModelResponse;
import java.io.File;
File audio = new File("/path/to/audio.wav");
NuwaAIClient.getInstance().getVoiceManager().createVoiceModel(audio, "音频文案", new NuwaCallback<VoiceModelResponse>() {
@Override
public void onSuccess(VoiceModelResponse data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.voiceSet(filePath, '音频文案');
{
"code": 200,
"model": [
{
"version": "1",
"name": "speech:声音克隆__e4ca50ff",
"url": "/nuwa-ai/4000170/voice/f2656220c9654cb292ddf6091e56f4b3.wav"
},
{
"version": "3",
"name": "index:声音克隆__dfb303370fc24d70b328593d4621ae3c",
"url": "/nuwa-ai/4000170/voice/ba3d776aaf7e4ee1951ee03a47b91f21.wav"
}
]
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| file | MultipartFile | 是 | 音频文件 |
| text | String | 是 | 音频文本内容 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 200:请求成功,非200 :请求失败 |
| model | Array | 声音模型列表 |
| model 对象属性 | | |
| version | String | 1:支持多国语言,3:仅支持中文 |
| name | String | 声音模型名称 |
| url | String | oss中声音模型路径 |
POST /web/voice/clone
await sdk.cloneVoice({ voiceName: "A0012", ... });
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
let voiceModel = ["version": "1", "name": "speech:声音克隆__e4ca50ff", "url": "/nuwa-ai/4000170/voice/f2656220c9654cb292ddf6091e56f4b3.wav"]
apiClient.cloneVoice(voiceName: "A0012", content: "你好,这是一段测试文本", voiceType: "5", sex: "1", age: "1", voiceTime: 5, featureList: ["大气活力"], model: voiceModel) { success, error in
if let error = error {
print("克隆声音失败: \(error.localizedDescription)")
return
}
if success {
print("克隆声音成功")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
NSDictionary *voiceModel = @{@"version": @"1", @"name": @"speech:声音克隆__e4ca50ff", @"url": @"/nuwa-ai/4000170/voice/f2656220c9654cb292ddf6091e56f4b3.wav"};
[apiClient cloneVoiceWithVoiceName:@"A0012" content:@"你好,这是一段测试文本" voiceType:@"5" sex:@"1" age:@"1" voiceTime:5 featureList:@[@"大气活力"] model:voiceModel completion:^(BOOL success, NSError * _Nullable error) {
if (error) {
NSLog(@"克隆声音失败: %@", error.localizedDescription);
return;
}
if (success) {
NSLog(@"克隆声音成功");
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.CloneVoiceRequest;
CloneVoiceRequest req = new CloneVoiceRequest();
req.setVoiceName("A0012");
NuwaAIClient.getInstance().getVoiceManager().cloneVoice(req, new NuwaCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.voiceClone({ voiceName: 'A0012', });
{
"code": 0,
"msg": null,
"data": true
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| voiceName | String | 是 | 声音显示名称 |
| content | String | 是 | 声音文本内容 |
| voiceType | String | 是 | 声音类型(3:豆包,5:复刻) |
| sex | String | 是 | 性别(1:男,2:女,3:中性) |
| age | String | 是 | 年龄(1:青年,2:中年,3:老年,4:儿童) |
| voiceTime | Integer | 是 | 声音时长(单位:秒) |
| featureList | Array | 否 | 声音特征 |
| model | Array | 是 | 声音模型 |
| model 对象属性 | | | |
| version | String | 是 | 1:支持多国语言,3:仅支持中文 |
| name | String | 是 | 声音模型名称 |
| url | String | 是 | oss中声音模型路径 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Boolean | true :成功,false:失败 |
DELETE /web/voice/delete/{id}
await sdk.deleteVoice("1935958397612609538");
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.deleteVoice("1935958397612609538") { success, error in
if let error = error {
print("删除声音失败: \(error.localizedDescription)")
return
}
if success {
print("删除声音成功")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient deleteVoice:@"1935958397612609538" completion:^(BOOL success, NSError * _Nullable error) {
if (error) {
NSLog(@"删除声音失败: %@", error.localizedDescription);
return;
}
if (success) {
NSLog(@"删除声音成功");
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getVoiceManager().deleteVoice("1935958397612609538", new NuwaCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.voiceDelete('1935958397612609538');
{
"code": 0,
"msg": null,
"data": true
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 声音Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Boolean | true :成功,false:失败 |
POST /web/voice/voiceList
await sdk.voiceList({ type: 1, current: 1, size: 10 });
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.getVoiceList(type: 1, current: 1, size: 10, age: nil, voiceName: nil, feature: nil) { result, error in
if let error = error {
print("获取声音列表失败: \(error.localizedDescription)")
return
}
if let result = result {
print("获取声音列表成功: \(result)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient getVoiceListWithType:1 current:1 size:10 age:nil voiceName:nil feature:nil completion:^(NSDictionary * _Nullable result, NSError * _Nullable error) {
if (error) {
NSLog(@"获取声音列表失败: %@", error.localizedDescription);
return;
}
if (result) {
NSLog(@"获取声音列表成功: %@", result);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.PageData;
import com.nuwaai.sdk.model.VoiceListRequest;
import com.nuwaai.sdk.model.VoiceRecord;
VoiceListRequest req = new VoiceListRequest();
req.setType(1);
req.setCurrent(1);
req.setSize(10);
NuwaAIClient.getInstance().getVoiceManager().getVoiceList(req, new NuwaCallback<PageData<VoiceRecord>>() {
@Override
public void onSuccess(PageData<VoiceRecord> data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.voiceList({ type: 1, current: 1, size: 10 });
{
"code": 0,
"msg": null,
"data": {
"records": [
{
"createTime": "2025-08-12 15:00:50",
"updateTime": "2025-08-12 15:00:50",
"voiceId": "1955162543697666049",
"voiceName": "热血青年",
"modeName": "index:测试1__06bd8d06",
"sex": "1",
"age": "1",
"voiceType": "5",
"feature": "大气活力",
"path": "/pub-nuwa/admin/audio/284ea5be2345470cbffef3aceecde81f.wav",
"systemFlag": "1",
"featureList": [
"大气活力"
]
},
{
"createTime": "2025-08-12 14:59:41",
"updateTime": "2025-08-12 14:59:41",
"voiceId": "1955162254982750210",
"voiceName": "少儿故事",
"modeName": "index:少儿故事__1b7293b3",
"sex": "1",
"age": "4",
"voiceType": "5",
"feature": "亲和力强",
"path": "/pub-nuwa/admin/audio/d5077c655c5e4dc3b35eb93e7d74b491.wav",
"systemFlag": "1",
"featureList": [
"亲和力强"
]
}
],
"total": 14,
"size": 2,
"current": 2,
"pages": 7
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| size | Long | 是 | 每页显示条数 |
| current | Long | 是 | 当前页(从1开始计数) |
| type | Integer | 是 | 查询类型(1:平台声音,2:我克隆的声音) |
| age | String | 否 | 年龄(1:青年,2:中年,3:老年,4:儿童) |
| voiceName | String | 否 | 声音显示名称 |
| feature | String | 否 | 声音特征 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| recods 属性 | | |
| createTime | LocalDateTime | 创建时间 |
| updateTime | LocalDateTime | 更新时间 |
| voiceId | Long | 声音id |
| voiceName | String | 声音显示名称 |
| modeName | String | 声音模型名称 |
| sex | String | 性别(1:男,2:女,3:中性) |
| age | String | 年龄(1:青年,2:中年,3:老年,4:儿童) |
| voiceTime | Integer | 声音时长(单位:秒) |
| voiceType | String | 声音类型(3:豆包,5:复刻) |
| feature | String | 声音特征 |
| path | String | 声音路径 |
| systemFlag | String | 声音权限(1:公开可见,2:仅个人可见) |
| featureList | Array | 声音特征列表 |
| 分页参数 | | |
| total | Long | 总记录数 |
| size | Long | 每页显示条数 |
| current | Long | 当前页(从1开始计数) |
| pages | Long | 总页数 |
POST /web/figure/create
await sdk.createFigure("A042");
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.createFigure("A042") { figureDetail, error in
if let error = error {
print("创建形象失败: \(error.localizedDescription)")
return
}
if let figureDetail = figureDetail {
print("创建形象成功: \(figureDetail)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient createFigure:@"A042" completion:^(NSDictionary * _Nullable figureDetail, NSError * _Nullable error) {
if (error) {
NSLog(@"创建形象失败: %@", error.localizedDescription);
return;
}
if (figureDetail) {
NSLog(@"创建形象成功: %@", figureDetail);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.FigureDetail;
NuwaAIClient.getInstance().getFigureManager().createFigure("A042", new NuwaCallback<FigureDetail>() {
@Override
public void onSuccess(FigureDetail data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.figureCreate({ figureName: 'A042' });
{
"code": 0,
"msg": null,
"data": {
"createBy": "18672393036",
"createTime": "2025-12-02 21:05:57",
"updateBy": "18672393036",
"updateTime": "2025-12-02 21:05:57",
"figureId": "1995841869673639938",
"figureName": "A042",
"status": "0",
"systemFlag": "2",
"client": "pc",
"channel": "natural",
"userId": "78"
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| figureName | String | 是 | 形象名称 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| 形象对象属性 | | |
| figureId | Long | 形象id |
| figureName | String | 形象名称 |
| status | String | 形象状态(0:待完善资料,1:创建中,2:创建成功,3:创建失败) |
| systemFlag | String | 形象权限(1:公开可见,2:仅个人可见) |
| userId | Long | 用户Id |
| createBy | String | 创建人 |
| updateBy | String | 更新人 |
| updateTime | LocalDateTime | 更新时间 |
| client | String | 客户端 |
| channel | String | 渠道 |
PUT /web/figure/edit
await sdk.editFigure({ figureId: "199...", ... });
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
let actionList = ["actionType": "0", "videoPath": "/nuwa/xx/action.mp4"]
apiClient.editFigure(figureId: "199...", figureName: "A042", videoPath: "/nuwa/xx/video.mp4", voiceType: "5", modeName: "index:测试1__06bd8d06", displayName: "测试声音", voicePath: nil, style: nil, age: "1", sex: "1", actionList: [actionList]) { taskId, error in
if let error = error {
print("修改形象失败: \(error.localizedDescription)")
return
}
if let taskId = taskId {
print("修改形象任务已提交,任务ID: \(taskId)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
NSDictionary *actionItem = @{@"actionType": @"0", @"videoPath": @"/nuwa/xx/action.mp4"};
NSArray *actionList = @[actionItem];
[apiClient editFigureWithFigureId:@"199..." figureName:@"A042" videoPath:@"/nuwa/xx/video.mp4" voiceType:@"5" modeName:@"index:测试1__06bd8d06" displayName:@"测试声音" voicePath:nil style:nil age:@"1" sex:@"1" actionList:actionList completion:^(NSString * _Nullable taskId, NSError * _Nullable error) {
if (error) {
NSLog(@"修改形象失败: %@", error.localizedDescription);
return;
}
if (taskId) {
NSLog(@"修改形象任务已提交,任务ID: %@", taskId);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.EditFigureRequest;
EditFigureRequest req = new EditFigureRequest();
req.setFigureId("199...");
NuwaAIClient.getInstance().getFigureManager().editFigure(req, new NuwaCallback<String>() {
@Override
public void onSuccess(String taskId) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.figureEdit({ figureId: '199...', });
{
"code": 0,
"msg": null,
"data": "db5945deccd24ad2bf13687b94c585d8"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| figureId | Long | 是 | 形象Id |
| figureName | String | 是 | 形象名称 |
| videoPath | String | 是 | oss中的视频路径 |
| voiceType | String | 是 | 声音类型(3:豆包,5:复刻) |
| modeName | String | 是 | 声音模型名称 |
| displayName | String | 是 | 声音显示名称 |
| voicePath | String | 否 | 声音文件路径 |
| style | String | 否 | 风格名称 |
| age | String | 是 | 年龄(1:青年,2:中年,3:老年,4:儿童) |
| sex | String | 是 | 性别(1:男,2:女,3:中性) |
| actionList | Array | 否 | 形象动作视频列表 |
| 动作视频对象属性 | | | |
| id | Long | 否 | 动作Id |
| actionType | String | 是 | 动作类型(0:开场白,1:情感表达,2:表演) |
| videoPath | String | 是 | Oss中动作视频路径 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | 请求Id,根据这个Id可以查询形象模型的生成状态 |
DELETE /web/figure/delete/{id}
await sdk.deleteFigure("199...");
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.deleteFigure("199...") { success, error in
if let error = error {
print("删除形象失败: \(error.localizedDescription)")
return
}
if success {
print("删除形象成功")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient deleteFigure:@"199..." completion:^(BOOL success, NSError * _Nullable error) {
if (error) {
NSLog(@"删除形象失败: %@", error.localizedDescription);
return;
}
if (success) {
NSLog(@"删除形象成功");
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getFigureManager().deleteFigure("199...", new NuwaCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.figureDelete('199...');
{
"code": 0,
"msg": null,
"data": true
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 形象Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Boolean | true: 成功,false:失败 |
POST /web/figure/figureList
await sdk.figureList({ type: 2, current: 1, size: 10 });
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.getFigureList(type: 2, current: 1, size: 10, age: nil, sex: nil, figureName: nil, style: nil) { result, error in
if let error = error {
print("获取形象列表失败: \(error.localizedDescription)")
return
}
if let result = result {
print("获取形象列表成功: \(result)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient getFigureListWithType:2 current:1 size:10 age:nil sex:nil figureName:nil style:nil completion:^(NSDictionary * _Nullable result, NSError * _Nullable error) {
if (error) {
NSLog(@"获取形象列表失败: %@", error.localizedDescription);
return;
}
if (result) {
NSLog(@"获取形象列表成功: %@", result);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.FigureListRequest;
import com.nuwaai.sdk.model.FigureRecord;
import com.nuwaai.sdk.model.PageData;
FigureListRequest req = new FigureListRequest();
req.setType(2);
req.setCurrent(1);
req.setSize(10);
NuwaAIClient.getInstance().getFigureManager().getFigureList(req, new NuwaCallback<PageData<FigureRecord>>() {
@Override
public void onSuccess(PageData<FigureRecord> data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.figureList({ type: 2, current: 1, size: 10 });
{
"code": 0,
"msg": null,
"data": {
"records": [
{
"createTime": "2025-12-02 21:05:57",
"updateTime": "2025-12-02 21:05:57",
"figureId": "1995841869673639938",
"figureName": "A042",
"thumbnailPath": /pub-nuwa/47/figure/1996947256201060354/53e2bc648edb4b68918d8936251544da.jpg,
"status": "0",
"systemFlag": "2",
"storage": "0",
"userId": "78",
"nickName": "王白玄龟"
},
{
"createTime": "2025-11-28 12:02:40",
"updateTime": "2025-11-28 12:06:29",
"figureId": "1994255593560322050",
"figureName": "星辰ixYb",
"thumbnailPath": "/pub-nuwa/78/figure/1994255593560322050/262f413c69914f718c30c9fedd53d692.jpg",
"status": "2",
"systemFlag": null,
"storage": "1584116",
"userId": "78",
"nickName": "王白玄龟"
}
],
"total": 8,
"size": 2,
"current": 1,
"pages": 4
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| current | Long | 是 | 当前页(从1开始) |
| size | Long | 是 | 每页显示条数 |
| type | Integer | 是 | 查询类型(1:平台形象,2:我的形象) |
| age | String | 否 | 年龄(1:青年,2:中年,3:老年,4:儿童) |
| sex | String | 否 | 性别(1:男,2:女,3:中性) |
| figureName | String | 否 | 形象名称 |
| style | String | 否 | 形象风格 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Array | 接口响应数据 |
| records对象属性 | | |
| figureId | Long | 形象Id |
| figureName | String | 形象名称 |
| userId | Long | 用户Id |
| nickName | String | 用户昵称 |
| thumbnailPath | String | 形象缩略图路径 |
| storage | Long | 占用存储空间大小(单位:Byte) |
| status | String | 形象状态(0:待完善资料,1:创建中,2:创建成功,3:创建失败) |
| createTime | LocalDateTime | 创建时间 |
| updateTime | LocalDateTime | 更新时间 |
GET /web/figure/detail/{figureId}
await sdk.figureDetail("199...");
import NuwaSDK
let apiClient = NuwaAPIClient(accessToken: "your-access-token")
apiClient.getFigureDetail("199...") { figureDetail, error in
if let error = error {
print("获取形象详情失败: \(error.localizedDescription)")
return
}
if let figureDetail = figureDetail {
print("获取形象详情成功: \(figureDetail)")
}
}
#import <NuwaSDK/NuwaSDK.h>
NuwaAPIClient *apiClient = [[NuwaAPIClient alloc] initWithAccessToken:@"your-access-token"];
[apiClient getFigureDetail:@"199..." completion:^(NSDictionary * _Nullable figureDetail, NSError * _Nullable error) {
if (error) {
NSLog(@"获取形象详情失败: %@", error.localizedDescription);
return;
}
if (figureDetail) {
NSLog(@"获取形象详情成功: %@", figureDetail);
}
}];
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.FigureDetail;
NuwaAIClient.getInstance().getFigureManager().getFigureDetail("199...", new NuwaCallback<FigureDetail>() {
@Override
public void onSuccess(FigureDetail data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.figureDetail('199...');
{
"code": 0,
"msg": null,
"data": {
"createBy": "",
"createTime": "2025-11-28 12:02:40",
"updateBy": "",
"updateTime": "2025-11-28 12:06:29",
"delFlag": "0",
"figureId": "1994255593560322050",
"figureName": "星辰ixYb",
"age": "1",
"sex": "2",
"style": null,
"startPath": "/nuwa/78/figure/1994255593560322050/13d93328e5c04802b22bb77378f69097.jpg",
"thumbnailPath": "/pub-nuwa/78/figure/1994255593560322050/262f413c69914f718c30c9fedd53d692.jpg",
"previewPath": null,
"figurePath": "/nuwa/78/figure/1994255593560322050/model.mp4",
"videoPath": "/nuwa/78/figure/1994255593560322050/0cc04aa4c8224a6b86dfd8a48e588665.mp4",
"voicePath": "",
"displayName": "中二少女",
"modeName": "index:飞销__cbbcc4ec",
"voiceType": "5",
"generaType": "3",
"preStatus": "0",
"status": "2",
"systemFlag": "2",
"failReason": "",
"storage": "1584116",
"client": "pc",
"channel": "natural",
"userId": "78"
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| figureId | Long | 是 | 形象Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| 形象对象属性 | | |
| figureId | Long | 形象id |
| figureName | String | 形象名称 |
| age | String | 年龄(1:青年,2:中年,3:老年,4:儿童) |
| sex | String | 性别(1:男,2:女,3:中性) |
| style | String | 形象风格 |
| thumbnailPath | String | 缩略图路径 |
| previewPath | String | 形象预览路径 |
| figurePath | String | 形象模型路径 |
| videoPath | String | 视频路径 |
| voicePath | String | 声音文件路径 |
| displayName | String | 声音显示名称 |
| modeName | String | 声音模型名称 |
| voiceType | String | 声音类型(3:豆包,5:复刻) |
| generaType | String | 生成模型的类型(1:根据图片生成,2:根据参考帧生成,3:根据视频生成) |
| preStatus | String | 形象预览状态(1:创建中,2:创建成功,3:创建失败) |
| status | String | 形象状态(0:待完善资料,1:创建中,2:创建成功,3:创建失败) |
| systemFlag | String | 形象权限(1:公开可见,2:仅个人可见) |
| failReason | String | 形象模型创建失败的原因 |
| actions | String | 动作列表 |
| client | String | 客户端 |
| channel | String | 渠道 |
| storage | Long | 占用存储空间大小(单位:Byte) |
| userId | Long | 用户Id |
| delFlag | String | 删除标记,1:已删除,0:正常 |
import NuwaSDK
class ViewController: UIViewController, NuwaClientDelegate {
private var nuwaClient: NuwaClient?
private var videoContainerView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
nuwaClient = NuwaClient(avatarId: "your_avatar_id", bizId: "your_biz_id", accessToken: "your_access_token")
nuwaClient?.delegate = self
videoContainerView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.width * 9/16))
videoContainerView.backgroundColor = .black
view.addSubview(videoContainerView)
}
func connect() {
guard let nuwaClient = nuwaClient else { return }
let videoView = nuwaClient.videoViewWithFrame(videoContainerView.bounds)
videoContainerView.addSubview(videoView)
nuwaClient.connect()
}
func disconnect() {
nuwaClient?.disconnect()
}
func sendTextMessage(_ text: String) {
nuwaClient?.sendTextMessage(text)
}
func sendControlMessage(_ content: String) {
nuwaClient?.sendControlMessage(content)
}
func sendAudioData(_ audioData: Data) {
nuwaClient?.sendAudioData(audioData)
}
func muteLocalAudio(_ mute: Bool) {
nuwaClient?.muteLocalAudio(mute)
}
func muteLocalVideo(_ mute: Bool) {
nuwaClient?.muteLocalVideo(mute)
}
func nuwaClientDidChangeState(_ state: NuwaConnectionState) {
switch state {
case .disconnected:
print("状态: 未连接")
case .connecting:
print("状态: 连接中...")
case .connected:
print("状态: 已连接")
case .reconnecting:
print("状态: 重新连接中...")
}
}
func nuwaClientDidConnect(_ sessionId: String) {
print("已连接,会话ID: \(sessionId)")
}
func nuwaClientDidDisconnect() {
print("连接已断开")
}
func nuwaClientDidReceiveMessage(_ message: [AnyHashable : Any]) {
print("收到消息: \(message)")
if let type = message["type"] as? String {
switch type {
case "avator-text":
if let text = message["data"] as? [String: Any], let content = text["text"] as? String {
print("数字人文本: \(content)")
}
case "chat":
if let data = message["data"] as? [String: Any], let content = data["content"] as? String {
print("聊天消息: \(content)")
}
case "asr-text":
if let data = message["data"] as? [String: Any], let content = data["content"] as? String {
print("语音识别: \(content)")
}
default:
break
}
}
}
func nuwaClientDidReceiveError(_ error: Error) {
print("错误: \(error.localizedDescription)")
}
func nuwaClientDidReceiveRemoteVideo(_ videoView: UIView) {
DispatchQueue.main.async {
videoView.frame = self.videoContainerView.bounds
self.videoContainerView.addSubview(videoView)
self.videoContainerView.bringSubviewToFront(videoView)
}
}
func nuwaClientDidReceiveRemoteAudio() {
print("收到远程音频")
}
}
#import <NuwaSDK/NuwaSDK.h>
@interface ViewController () <NuwaClientDelegate>
@property (nonatomic, strong) NuwaClient *nuwaClient;
@property (nonatomic, strong) UIView *videoContainerView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.nuwaClient = [[NuwaClient alloc] initWithAvatarId:@"your_avatar_id" bizId:@"your_biz_id" accessToken:@"your_access_token"];
self.nuwaClient.delegate = self;
self.videoContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width * 9/16)];
self.videoContainerView.backgroundColor = [UIColor blackColor];
[self.view addSubview:self.videoContainerView];
}
- (void)connect {
UIView *videoView = [self.nuwaClient videoViewWithFrame:self.videoContainerView.bounds];
[self.videoContainerView addSubview:videoView];
[self.nuwaClient connect];
}
- (void)disconnect {
[self.nuwaClient disconnect];
}
- (void)sendTextMessage:(NSString *)text {
[self.nuwaClient sendTextMessage:text];
}
- (void)sendControlMessage:(NSString *)content {
[self.nuwaClient sendControlMessage:content];
}
- (void)sendAudioData:(NSData *)audioData {
[self.nuwaClient sendAudioData:audioData];
}
- (void)muteLocalAudio:(BOOL)mute {
[self.nuwaClient muteLocalAudio:mute];
}
- (void)muteLocalVideo:(BOOL)mute {
[self.nuwaClient muteLocalVideo:mute];
}
#pragma mark - NuwaClientDelegate
- (void)nuwaClientDidChangeState:(NuwaConnectionState)state {
switch (state) {
case NuwaConnectionStateDisconnected:
NSLog(@"状态: 未连接");
break;
case NuwaConnectionStateConnecting:
NSLog(@"状态: 连接中...");
break;
case NuwaConnectionStateConnected:
NSLog(@"状态: 已连接");
break;
case NuwaConnectionStateReconnecting:
NSLog(@"状态: 重新连接中...");
break;
}
}
- (void)nuwaClientDidConnect:(NSString *)sessionId {
NSLog(@"已连接,会话ID: %@", sessionId);
}
- (void)nuwaClientDidDisconnect {
NSLog(@"连接已断开");
}
- (void)nuwaClientDidReceiveMessage:(NSDictionary *)message {
NSLog(@"收到消息: %@", message);
NSString *type = message[@"type"];
if ([type isEqualToString:@"avator-text"]) {
NSString *text = message[@"data"][@"text"];
if (text) {
NSLog(@"数字人文本: %@", text);
}
} else if ([type isEqualToString:@"chat"]) {
NSString *content = message[@"data"][@"content"];
if (content) {
NSLog(@"聊天消息: %@", content);
}
} else if ([type isEqualToString:@"asr-text"]) {
NSString *content = message[@"data"][@"content"];
if (content) {
NSLog(@"语音识别: %@", content);
}
}
}
- (void)nuwaClientDidReceiveError:(NSError *)error {
NSLog(@"错误: %@", error.localizedDescription);
}
- (void)nuwaClientDidReceiveRemoteVideo:(UIView *)videoView {
dispatch_async(dispatch_get_main_queue(), ^{
videoView.frame = self.videoContainerView.bounds;
[self.videoContainerView addSubview:videoView];
[self.videoContainerView bringSubviewToFront:videoView];
});
}
- (void)nuwaClientDidReceiveRemoteAudio {
NSLog(@"收到远程音频");
}
@end
POST /web/digital/user/create
await sdk.createDigitalUser("A020");
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.DigitalUserRecord;
NuwaAIClient.getInstance().getDigitalUserManager().create("A020", new NuwaCallback<DigitalUserRecord>() {
@Override
public void onSuccess(DigitalUserRecord data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.digitalUserCreate({ name: 'A020' });
{
"code": 0,
"msg": null,
"data": {
"createBy": "18672393036",
"createTime": "2025-12-04 21:29:59",
"updateBy": "18672393036",
"updateTime": "2025-12-04 21:29:59",
"delFlag": "0",
"id": "1996572693326966785",
"name": "A020",
"status": "0",
"client": "pc",
"channel": "natural",
"userId": "78",
"systemFlag": "2"
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| name | String | 是 | 智能体名称 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| 智能体对象属性 | | |
| id | Long | 智能体Id |
| name | String | 智能体名称 |
| status | String | 智能体状态(0:待完善资料,1:创建中,2:创建成功,3:创建失败) |
| client | String | 客户端(pc,h5) |
| channel | String | 渠道 |
| userId | Long | 用户Id |
| systemFlag | String | 智能体权限(1:公开可见,2:仅个人可见) |
| createBy | String | 创建人 |
| createTime | LocalDateTime | 创建时间 |
| updateBy | String | 更新人 |
| updateTime | LocalDateTime | 更新时间 |
| delFlag | String | 删除标记,1:已删除,0:正常 |
PUT /web/digital/user/edit
await sdk.editDigitalUser({ id: "199...", ... });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.DigitalUserEditRequest;
DigitalUserEditRequest req = new DigitalUserEditRequest();
req.setId("199...");
NuwaAIClient.getInstance().getDigitalUserManager().edit(req, new NuwaCallback<String>() {
@Override
public void onSuccess(String taskId) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.digitalUserEdit({ id: '199...', });
{
"code": 0,
"msg": null,
"data": "aced3bf3189c4576817fd590a6d397b7"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 智能体Id |
| name | String | 是 | 智能体名称 |
| age | String | 是 | 智能体年龄 |
| sex | String | 是 | 性别(1:男,2:女,3:中性) |
| musicName | String | 否 | 背景音乐显示名称 |
| musicPath | String | 否 | 背景音乐路径 |
| musicVolume | Long | 否 | 背景音乐音量 |
| keyWords | String | 否 | 热词 |
| shapeMouth | String | 是 | 嘴型 |
| speedSpeech | String | 是 | 语速 |
| driveMode | String | 是 | 驱动模式(0:反向,1:正向) |
| detectMode | String | 否 | 检测模式(0:强检测,1:弱检测) |
| roleId | Long | 是 | 角色Id |
| roleName | String | 是 | 角色名称 |
| applicationScenarios | String | 否 | 应用场景编号 |
| specialty | String | 否 | 专业背景 |
| personality | String | 否 | 性格特点 |
| languageStyle | String | 否 | 语言风格 |
| goal | String | 否 | 对话目标 |
| figureId | BigDecimal | 否 | 形象Id |
| openText | String | 否 | 开场白,最多1000字符 |
| detectFlag | String | 否 | 冷场检测标记(0:关闭,1:开启) |
| silentTime | Integer | 否 | 冷场时间(单位:秒) |
| recommend1 | String | 否 | 推荐提问1,最多200字符 |
| recommend2 | String | 否 | 推荐提问2,最多200字符 |
| recommend3 | String | 否 | 推荐提问3,最多200字符 |
| remark | String | 否 | 指引 |
| skillList | Array | 否 | 技能列表 |
| 技能对象属性 | | | |
| skillName | String | 是 | 技能名称 |
| enabled | String | 是 | 是否启用(1:启用,0:未启用) |
| cardList | Array | 否 | 桌面卡片列表 |
| 卡片对象属性 | | | |
| cardName | String | 是 | 卡片名称 |
| enabled | String | 是 | 是否启用(1:启用,0:未启用) |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | 创建智能体模型的任务Id,为空时表示不需要床创建智能体模型,更新绑定的形象模型时才会触发创建智能体模型任务 |
DELETE /web/digital/user/delete/{id}
await sdk.deleteDigitalUser("199...");
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getDigitalUserManager().delete("199...", new NuwaCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.digitalUserDelete('199...');
{
"code": 0,
"msg": null,
"data": true
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 智能体Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Boolean | true:成功,false:失败 |
POST /web/digital/user/digitalList
await sdk.digitalUserList({ type: 2, current: 1, size: 10 });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.DigitalUserListRequest;
import com.nuwaai.sdk.model.DigitalUserRecord;
import com.nuwaai.sdk.model.PageData;
DigitalUserListRequest req = new DigitalUserListRequest();
req.setType(2);
req.setCurrent(1);
req.setSize(10);
NuwaAIClient.getInstance().getDigitalUserManager().getList(req, new NuwaCallback<PageData<DigitalUserRecord>>() {
@Override
public void onSuccess(PageData<DigitalUserRecord> data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.digitalList({ type: 2, current: 1, size: 10 });
{
"code": 0,
"msg": null,
"data": {
"records": [
{
"createTime": "2025-12-04 21:29:59",
"updateTime": "2025-12-04 21:29:59",
"id": "1996572693326966785",
"name": "A020",
"status": "0",
"knowledgeStorage": "0",
"userId": "78",
"systemFlag": "2",
"nickName": "王白玄龟",
},
{
"createTime": "2025-11-27 11:17:02",
"updateTime": "2025-11-28 11:31:07",
"id": "1993881722078064641",
"name": "76d64eac",
"roleName": "小云",
"thumbnailPath": "/pub-nuwa/1/figure/1955077707972714497/69c52b2e195444aa973cdf1a94286f69.jpg",
"status": "2",
"knowledgeStorage": "0",
"userId": "78",
"systemFlag": "2",
"nickName": "王白玄龟"
}
],
"total": 4,
"size": 2,
"current": 1,
"pages": 2
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| type | Integer | 是 | 查询类型(1:平台数字人,2:我的数字人) |
| current | Long | 是 | 当前页(从1开始) |
| size | Long | 是 | 每页记录数 |
| name | String | 否 | 智能体名称 |
| age | String | 否 | 年龄(1:青年,2:中年,3:老年,4:儿童) |
| sex | String | 否 | 性别(1:男,2:女,3:中性) |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| records | Array | 智能体列表 |
| current | Long | 当前页(从1 开始) |
| size | Long | 每页记录数 |
| total | Long | 总记录数 |
| pages | Long | 总页数 |
| 智能体对象属性 | | |
| id | Long | 智能体Id |
| name | String | 智能体名称 |
| status | String | 智能体状态(0:待完善资料,1:创建中,2:创建成功,3:创建失败) |
| systemFlag | String | 智能体权限(1:公开可见,2:仅个人可见) |
| userId | Long | 用户Id |
| nickName | String | 用户昵称 |
| knowledgeStorage | Long | 占用空间大小(单位:Byte) |
| roleName | String | 角色名称 |
| thumbnailPath | String | 缩略图路径 |
| applicationScenariosName | String | 应用场景名称 |
| createTime | LocalDateTime | 创建时间 |
| updateTime | LocalDateTime | 更新时间 |
GET /web/role/list
await sdk.roleList({ roleName: "", current: 1, size: 10 });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.PageData;
import com.nuwaai.sdk.model.RoleRecord;
NuwaAIClient.getInstance().getDigitalUserManager().getRoleList("", 10, 1, new NuwaCallback<PageData<RoleRecord>>() {
@Override
public void onSuccess(PageData<RoleRecord> data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.roleList({ roleName: '', current: 1, size: 10 });
{
"code": 0,
"msg": null,
"data": {
"records": [
{
"createTime": "2025-11-08 20:12:13",
"updateTime": "2025-11-08 20:12:13",
"roleId": "1987131038946664449",
"roleName": "直播带货11",
"applicationScenarios": "0",
"language": "1",
"specialty": "",
"personality": "",
"languageStyle": "",
"goal": "",
"workThinking": "",
"modelName": "",
"skillList": [
{
"skillName": "PPT演讲",
"enabled": "1"
}
],
"nickName": null
},
{
"createTime": "2025-11-03 12:06:25",
"updateTime": "2025-11-08 20:12:03",
"roleId": "1985196841234313218",
"roleName": "直播带货",
"applicationScenarios": "0",
"language": "0",
"specialty": "11",
"personality": "22",
"languageStyle": "33",
"goal": "44",
"workThinking": "55",
"modelName": "66",
"description": "77",
"skillList": [
{
"skillName": "知识问答",
"enabled": "1"
},
{
"skillName": "PPT演讲",
"enabled": "1"
},
{
"skillName": "文件发送",
"enabled": "1"
},
{
"skillName": "福利设定",
"enabled": "1"
}
],
"nickName": null
}
],
"total": 22,
"size": 2,
"current": 1,
"pages": 11
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| current | Long | 是 | 当前页(从1开始) |
| size | Long | 是 | 每页记录数 |
| roleName | String | 否 | 角色名称 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| records | Array | 角色列表 |
| current | Long | 当前页(从1 开始) |
| size | Long | 每页记录数 |
| total | Long | 总记录数 |
| pages | Long | 总页数 |
| 角色对象属性 | | |
| roleId | Long | 角色编号 |
| roleName | String | 角色名称 |
| language | String | 语种(0:文中,1:英文) |
| specialty | String | 专业背景 |
| personality | String | 性格特征 |
| languageStyle | String | 语言风格 |
| goal | String | 对话目标 |
| nickName | String | 创建人昵称 |
| applicationScenarios | String | 应用场景编号 |
| workThinking | String | 工作思维 |
| modelName | String | 角色模型名称 |
| createTime | LocalDateTime | 创建时间 |
| updateTime | LocalDateTime | 更新时间 |
| skillList | Array | 技能列表 |
| 技能属性 | | |
| skillName | String | 技能名称 |
| enabled | String | 是否启用(1:启用,0:未启用) |
POST /web/document/4.0/add
await sdk.addDocumentInfo({ fileSize: 27451057, digitalUserId: 199..., originalFilename: "demo.pdf" });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.AddDocumentRequest;
import com.nuwaai.sdk.model.AddDocumentResult;
AddDocumentRequest req = new AddDocumentRequest();
req.setFileSize(27451057);
req.setDigitalUserId(1996572693326966785L);
req.setOriginalFilename("demo.pdf");
NuwaAIClient.getInstance().getDocumentManager().addDocument(req, new NuwaCallback<AddDocumentResult>() {
@Override
public void onSuccess(AddDocumentResult data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.documentAdd4({
fileSize: 27451057,
digitalUserId: 1996572693326966785,
originalFilename: 'demo.pdf'
});
{
"code": 0,
"msg": null,
"data": {
"documentId": "7131",
"preUploadUrl": "https://nuwa-ai.oss-cn-shenzhen.aliyuncs.com/54/knowledge/2034192955560034305/f03fccd5e1ef41d3a36ad7c2473222ad.pptx?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20260320T014105Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=LTAI5tHbpo83YpipHibjKr4L%2F20260320%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=7ad481ed6e4f0411d1ad8915270e0f2094e813febc358258af9162c649951389"
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| fileSize | Long | 是 | 文件大小(单位:Byte) |
| digitalUserId | Long | 是 | 数字人ID |
| originalFilename | String | 是 | 原始文件名称 |
| description | String | 否 | 描述 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| documentId | Long | 文档Id |
| preUploadUrl | String | 预上传地址 |
POST /web/document/importWebsite
await sdk.importWebsite("www.nuwaai.com", 199...);
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.ImportWebsiteRequest;
ImportWebsiteRequest req = new ImportWebsiteRequest();
req.setUrl("www.nuwaai.com");
req.setDigitalUserId(1996572693326966785L);
NuwaAIClient.getInstance().getDocumentManager().importWebsite(req, new NuwaCallback<String>() {
@Override
public void onSuccess(String documentId) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.documentImportWebsite({
url: 'www.nuwaai.com',
digitalUserId: 1996572693326966785
});
{
"code": 0,
"msg": null,
"data": "7133"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| url | String | 是 | 网站地址 |
| digitalUserId | Long | 是 | 智能体Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Long | 文档Id |
PUT {preUploadUrl}
const addRes = await sdk.addDocumentInfo({
fileSize: file.size,
digitalUserId,
originalFilename: file.name,
description: ""
});
await sdk.uploadKnowledgeByPreSignedUrl(addRes.data.preUploadUrl, file);
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.AddDocumentRequest;
import com.nuwaai.sdk.model.AddDocumentResult;
import java.io.File;
File file = new File("/path/to/demo.pdf");
long digitalUserId = 1996572693326966785L;
AddDocumentRequest addReq = new AddDocumentRequest();
addReq.setFileSize(file.length());
addReq.setDigitalUserId(digitalUserId);
addReq.setOriginalFilename(file.getName());
addReq.setDescription("");
NuwaAIClient.getInstance().getDocumentManager().addDocument(addReq, new NuwaCallback<AddDocumentResult>() {
@Override
public void onSuccess(AddDocumentResult data) {
String path = file.getAbsolutePath();
String uploadUrl = data.getPreUploadUrl();
NuwaAIClient.getInstance().getDocumentManager().uploadDocumentFile(path, uploadUrl, new NuwaCallback<Void>() {
@Override
public void onSuccess(Void unused) { }
@Override
public void onFailure(int code, String message) { }
});
}
@Override
public void onFailure(int code, String message) { }
});
const addRes = await sdk.documentAdd4({
fileSize,
digitalUserId,
originalFilename: fileName,
description: ''
});
await sdk.uploadKnowledgeFile(addRes.preUploadUrl, tempFilePath);
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| preUploadUrl | String | 是 | 预上传地址,新增文档信息接口返回,前端直接请求预上传地址接口上传文件 |
POST /web/document/removeV2
await sdk.removeDocuments({ digitalUserId: 199..., docIds: [7131] });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.RemoveDocumentRequest;
import java.util.Arrays;
RemoveDocumentRequest req = new RemoveDocumentRequest();
req.setDigitalUserId(1996572693326966785L);
req.setDocIds(Arrays.asList(7131L));
NuwaAIClient.getInstance().getDocumentManager().removeDocument(req, new NuwaCallback<Object>() {
@Override
public void onSuccess(Object data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.documentRemoveV2({ digitalUserId: 1996572693326966785, docIds: [7131] });
{
"code": 0,
"msg": null,
"data": null
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| digitalUserId | Long | 是 | 智能体Id |
| docIds | Long[] | 是 | 文档Id集合 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
POST /web/document/modifyV2
await sdk.modifyDocument(7131, 0, file);
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import java.io.File;
File file = new File("/path/to/demo.pdf");
NuwaAIClient.getInstance().getDocumentManager().modifyDocument(7131L, 0, file, new NuwaCallback<Object>() {
@Override
public void onSuccess(Object data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.documentModifyV2('7131', 0, tempFilePath);
{
"code": 0,
"msg": null,
"data": null
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| file | MultipartFile | 是 | 知识文档 |
| docId | Long | 是 | 文档Id |
| editType | Integer | 是 | 文档类型(0:图片/视频,1:文本文档,2:ppt,3: URL) |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
GET /web/document/getDocumentById
await sdk.getDocumentById("7131");
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.DocumentRecord;
NuwaAIClient.getInstance().getDocumentManager().getDocument("7131", new NuwaCallback<DocumentRecord>() {
@Override
public void onSuccess(DocumentRecord data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.getDocumentById('7131');
{
"code": 0,
"msg": null,
"data": {
"id": "7131",
"analysisUrl": "4000170/knowledge/1996852095362637826/b6aa31c01ab843f5bd3e9b309e77a294.md",
"filePath": "4000170/knowledge/1996852095362637826/f53c7e92d8aa48e58814dfd93e47f79b.pdf",
"type": "pdf",
"original": "Nuwaai介绍手册2505-邦彦技术.pdf",
"sendPermission": "1",
"playPermission": "1",
"description": null,
"category": 1,
"createTime": "2025-12-06 11:27:11",
"updateTime": "2025-12-06 16:03:09",
"status": "1",
"reason": null
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| docId | String | 是 | 文档Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| 对象属性 | | |
| id | Long | 文档Id |
| analysisUrl | String | 解析后的文件地址 |
| type | String | 文档类型 |
| original | String | 原始文件名 |
| sendPermission | String | 发送权限(0:关闭,1:开启) |
| playPermission | String | 播放权限(0:关闭,1:开启) |
| description | String | 描述 |
| category | String | 文档类型(0:图片/视频,1:文本文档,2:ppt,3: URL) |
| status | String | 状态(0:解析中,1:解析成功,2:解析失败) |
| reason | String | 失败原因 |
| createTime | LocalDateTime | 上传时间 |
| updateTime | LocalDateTime | 更新时间 |
GET /web/document/pageV2
await sdk.pageDocuments({ digitalUserId: 199..., current: 1, size: 10 });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.DocumentRecord;
import com.nuwaai.sdk.model.PageData;
NuwaAIClient.getInstance().getDocumentManager().getDocumentPage(
1996572693326966785L, 10, 1, null, null,
new NuwaCallback<PageData<DocumentRecord>>() {
@Override
public void onSuccess(PageData<DocumentRecord> data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.documentPageV2({
digitalUserId: 1996572693326966785,
current: 1,
size: 10
});
{
"code": 0,
"msg": null,
"data": {
"records": [
{
"id": "7130",
"analysisUrl": "4000170/knowledge/1996852095362637826/fb3187e71a5944bba8bd9e4e75b4b65a.md",
"filePath": "www.nuwaai.com",
"type": "web",
"original": "www.nuwaai.com",
"sendPermission": "1",
"playPermission": "1",
"description": null,
"category": 3,
"createTime": "2025-12-06 11:17:59",
"updateTime": "2025-12-06 11:18:42",
"status": "1",
"reason": null
}
],
"total": 1,
"size": 10,
"current": 1,
"pages": 1
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| digitalUserId | Long | 是 | 数字人ID |
| current | Long | 是 | 当前页(从1 开始) |
| size | Long | 是 | 每页记录数 |
| type | String | 否 | 文档类型 |
| documentName | String | 否 | 文档名称 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| 对象属性 | | |
| id | Long | 文档Id |
| analysisUrl | String | 解析后的文件地址 |
| filePath | String | 原始文档路径 |
| type | String | 文档类型 |
| original | String | 原始文件名 |
| sendPermission | String | 发送权限(0:关闭,1:开启) |
| playPermission | String | 播放权限(0:关闭,1:开启) |
| description | String | 描述 |
| category | String | 文档类型(0:图片/视频,1:文本文档,2:ppt,3: URL) |
| status | String | 状态(0:解析中,1:解析成功,2:解析失败) |
| reason | String | 失败原因 |
| createTime | LocalDateTime | 上传时间 |
| updateTime | LocalDateTime | 更新时间 |
POST /web/talent/create
await sdk.createTalent("1");
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.CreateTalentRequest;
import com.nuwaai.sdk.model.TalentDetail;
CreateTalentRequest req = new CreateTalentRequest();
req.setType("1");
NuwaAIClient.getInstance().getTalentManager().create(req, new NuwaCallback<TalentDetail>() {
@Override
public void onSuccess(TalentDetail data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.talentCreate({ type: '1' });
{
"code": 0,
"msg": null,
"data": {
"createBy": "18672393036",
"createTime": "2025-12-12 09:41:40",
"updateBy": "18672393036",
"updateTime": "2025-12-12 09:41:40",
"delFlag": "0",
"id": "1999293545418145794",
"name": "e0bc2e17",
"type": "1",
"client": "pc",
"channel": "natural",
"userId": "47",
"systemFlag": "2"
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| type | String | 是 | 才艺类型(1:个人演唱,2:个人演讲) |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| 才艺对象属性 | | |
| createBy | String | 创建人 |
| createTime | LocalDateTime | 创建时间 |
| updateBy | String | 更新人 |
| updateTime | LocalDateTime | 更新时间 |
| id | Long | 才艺Id |
| name | String | 才艺名称 |
| type | String | 才艺类型(1:个人演唱,2:个人演讲) |
| client | String | 客户端 |
| channel | String | 渠道 |
| userId | Long | 用户Id |
| systemFlag | String | 才艺权限(1:公开可见,2:仅个人可见) |
PUT /web/talent/edit
await sdk.editTalent({ id: "199...", ... });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.EditTalentRequest;
EditTalentRequest req = new EditTalentRequest();
req.setId("199...");
NuwaAIClient.getInstance().getTalentManager().edit(req, new NuwaCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.talentEdit({ id: '199...', });
{
"code": 0,
"msg": null,
"data": true
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 才艺编号 |
| name | String | 是 | 才艺名称 |
| type | String | 是 | 才艺类型(1:个人演唱,2:个人演讲) |
| videoPath | String | 是 | 场景视频路径 |
| style | String | 否 | 风格 |
| songId | Long | 否 | 音乐Id |
| songPath | String | 否 | 音乐路径 |
| songName | String | 否 | 音乐名称 |
| songFrom | String | 否 | 音乐来源(1:平台,2:我创作的,3:本地上传) |
| lyric | String | 否 | 歌词文件路径 |
| subtitlesStatus | String | 是 | 字幕状态(0:不开启,1:开启) |
| acappella | String | 否 | 分离的人声音路径 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Boolean | true:成功,false:失败 |
DELETE /web/talent/delete/{id}
await sdk.deleteTalent("199...");
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
NuwaAIClient.getInstance().getTalentManager().delete("199...", new NuwaCallback<Boolean>() {
@Override
public void onSuccess(Boolean data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.talentDelete('199...');
{
"code": 0,
"msg": null,
"data": true
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 才艺Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Booelan | true:成功,false:失败 |
POST /web/talent/preview
await sdk.previewTalent({ id: "199...", ... });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.PreviewTalentRequest;
PreviewTalentRequest req = new PreviewTalentRequest();
req.setId("199...");
NuwaAIClient.getInstance().getTalentManager().preview(req, new NuwaCallback<String>() {
@Override
public void onSuccess(String requestId) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.talentPreview({ id: '199...', });
{
"code": 0,
"msg": null,
"data": "a516fb5714484f14bfb4723bbaa9dc0d"
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 才艺编号 |
| name | String | 是 | 才艺名称 |
| type | String | 是 | 才艺类型(1:个人演唱,2:个人演讲) |
| videoPath | String | 是 | 场景视频路径 |
| style | String | 否 | 风格 |
| songId | Long | 否 | 音乐Id |
| songPath | String | 否 | 音乐路径,个人演唱必填,个人演讲非必填 |
| songName | String | 否 | 音乐名称 |
| songFrom | String | 否 | 音乐来源(1:平台,2:我创作的,3:本地上传) |
| lyric | String | 否 | 歌词文件路径,个人演唱必填,个人演讲非必填 |
| subtitlesStatus | String | 是 | 字幕状态(0:不开启,1:开启) |
| acappella | String | 是 | 分离的人声音路径,个人演唱必填,个人演讲非必填 |
| voiceType | String | 否 | 声音类型(3:豆包,5:复刻),个人演讲必填,个人演唱非必填 |
| modeName | String | 否 | 声音模型名称,个人演讲必填,个人演唱非必填 |
| speechText | String | 否 | 演讲文案,个人演讲必填,个人演唱非必填 |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | String | 请求Id,用于查询才艺是视频生成结果 |
POST /web/talent/talentList
await sdk.talentList({ current: 1, size: 10, systemFlag: "2" });
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.PageData;
import com.nuwaai.sdk.model.TalentListRequest;
import com.nuwaai.sdk.model.TalentRecord;
TalentListRequest req = new TalentListRequest();
req.setCurrent(1);
req.setSize(10);
req.setSystemFlag("2");
NuwaAIClient.getInstance().getTalentManager().getList(req, new NuwaCallback<PageData<TalentRecord>>() {
@Override
public void onSuccess(PageData<TalentRecord> data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.talentList({ current: 1, size: 10, systemFlag: '2' });
{
"code": 0,
"msg": null,
"data": {
"records": [
{
"createTime": "2025-12-01 16:02:11",
"updateTime": "2025-12-01 18:01:55",
"id": "1995403034264707074",
"name": "b3baac21",
"type": "1",
"thumbnailPath": "/pub-nuwa/4000170/talent/1995403034264707074/0f5bf4fd6e934ab7b3fbdef049505b6c.jpg",
"preStatus": "0",
"storage": "4906412",
"userId": "4000170",
"nickName": "林墨麟"
},
{
"createTime": "2025-12-01 09:16:14",
"updateTime": "2025-12-01 09:20:44",
"id": "1995300872645877762",
"name": "青春旋律",
"type": "1",
"thumbnailPath": "/pub-nuwa/4000170/talent/1995300872645877762/df380a72f7ef4b4bb513ced80e7c544c.jpg",
"preStatus": "2",
"storage": "41966629",
"userId": "4000170",
"nickName": "林墨麟"
}
],
"total": 22,
"size": 2,
"current": 1,
"pages": 11
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| current | Long | 是 | 当前页 |
| size | Long | 是 | 每页记录数 |
| systemFlag | String | 是 | 权限(1:公开可见,2:仅个人可见) |
| name | String | 否 | 才艺名称 |
| type | String | 否 | 才艺类型(1:个人演唱,2:个人演讲) |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| records | Array | 才艺列表 |
| current | Long | 当前页(从1 开始) |
| size | Long | 每页记录数 |
| total | Long | 总记录数 |
| pages | Long | 总页数 |
| 才艺对象属性 | | |
| id | Long | 才艺Id |
| name | String | 才艺名称 |
| type | String | 才艺类型(1:个人演唱,2:个人演讲) |
| thumbnailPath | String | 视频缩略图路径 |
| storage | Long | 占用存储空间大小(单位:Byte) |
| userId | Long | 用户Id |
| nickName | String | 用户昵称 |
| createTime | LocalDateTime | 创建时间 |
| updateTime | LocalDateTime | 更新时间 |
GET /web/talent/detail/{id}
await sdk.talentDetail("199...");
import com.nuwaai.sdk.NuwaAIClient;
import com.nuwaai.sdk.NuwaCallback;
import com.nuwaai.sdk.model.TalentDetail;
NuwaAIClient.getInstance().getTalentManager().getDetail("199...", new NuwaCallback<TalentDetail>() {
@Override
public void onSuccess(TalentDetail data) { }
@Override
public void onFailure(int code, String message) { }
});
await sdk.talentDetail('199...');
{
"code": 0,
"msg": null,
"data": {
"createTime": "2025-11-25 14:29:56",
"updateTime": "2025-11-25 21:18:30",
"id": "1993205490860269569",
"name": "A0012",
"type": "2",
"previewPath": "/nuwa-ai/talent/1993205490860269569/video-3f6bacb0400b403d98e1a6b70df7821b.mp4",
"videoPath": "/nuwa-ai/4000170/talent/1993205490860269569/d6056ccbea144ffaaa2e1cbb6f25b7b7.mp4",
"thumbnailPath": "/pub-nuwa/4000170/talent/1993205490860269569/14b459fe4ca344f7ba05ef1c68d137bb.jpg",
"style": "现代",
"songId": "74",
"songPath": "/pub-nuwa/admin/music/8c95aa1cee1d4c89b328478b3b50e269.mp3",
"songFrom": "1",
"songName": "假如给我三天光明",
"songVolume": 0.5,
"subtitlesStatus": "0",
"labiate": 1.5,
"acappella": null,
"lyric": null,
"soundPath": "/pub-nuwa/admin/audio/571901a4f8974cedafc081c9ce5c9006.wav",
"soundName": "新闻女主播",
"speedSpeech": 1,
"speechText": ""
"voiceType": "5",
"modeName": "index:新闻女主播__d67c8ff2",
"preStatus": "2",
"storage": "60905886",
"client": "pc",
"channel": "natural",
"userId": "4000170",
"systemFlag": "2"
}
}
| 参数名 | 参数类型 | 是否必填 | 参数说明 |
|---|
| id | Long | 是 | 才艺Id |
| 参数名 | 参数类型 | 参数说明 |
|---|
| code | Integer | 0:请求成功,非0 :请求失败 |
| msg | String | 响应码 描述 |
| data | Object | 接口响应数据 |
| id | Long | 才艺Id |
| name | String | 才艺名称 |
| type | String | 才艺类型(1:个人演唱,2:个人演讲) |
| previewPath | String | 生成的才艺视频路径 |
| videoPath | String | 场景视频路径 |
| thumbnailPath | String | 视频缩略图路径 |
| style | String | 风格 |
| songId | Long | 音乐Id |
| songPath | String | 音乐路径 |
| songFrom | String | 音乐来源(1:平台,2:我创作的,3:本地上传) |
| songName | String | 音乐显示名称 |
| songVolume | BigDecimal | 音乐音量 |
| subtitlesStatus | String | 字幕状态(0:不开启,1:开启) |
| labiate | BigDecimal | 唇形 |
| acappella | String | 分离的人声音路径 |
| lyric | String | 歌词文件路径 |
| soundPath | String | 演讲声音路径 |
| soundName | String | 演讲声音显示名称 |
| speedSpeech | BigDecimal | 语速 |
| speechText | String | 演讲文案 |
| voiceType | String | 声音类型(3:豆包,5:复刻) |
| modeName | String | 声音模型名称 |
| preStatus | String | 才艺预览地址状态(1:创建中,2:创建成功,3:创建失败) |
| actions | String | 动作列表 |
| storage | Long | 占用存储空间大小(单位:Byte) |
| client | String | 客户端 |
| channel | String | 渠道 |
| userId | Long | 用户Id |
| systemFlag | String | 权限(1:公开可见,2:仅个人可见) |