Add kling (#200)
This commit is contained in:
1 parent
e12c9d96cc
commit
5f0ec79e83
43 files changed
+2718
No files matched your search
@@ -14,6 +14,7 @@ export * from './credential';
|
||||
export * from './qrart';
|
||||
export * from './luma';
|
||||
export * from './pika';
|
||||
export * from './kling';
|
||||
export * from './flux';
|
||||
export * from './hailuo';
|
||||
export * from './headshots';
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import { IKlingGenerateRequest, IKlingGenerateResponse, IKlingTaskResponse, IKlingTasksResponse } from '@/models';
|
||||
import { BASE_URL_API } from '@/constants';
|
||||
|
||||
class KlingOperator {
|
||||
async task(id: string, options: { token: string }): Promise<AxiosResponse<IKlingTaskResponse>> {
|
||||
return await axios.post(
|
||||
`/kling/tasks`,
|
||||
{
|
||||
action: 'retrieve',
|
||||
id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'x-record-exempt': 'true'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async tasks(
|
||||
filter: {
|
||||
ids?: string[];
|
||||
applicationId?: string;
|
||||
userId?: string;
|
||||
type?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
createdAtMax?: number;
|
||||
createdAtMin?: number;
|
||||
},
|
||||
options: { token: string }
|
||||
): Promise<AxiosResponse<IKlingTasksResponse>> {
|
||||
return await axios.post(
|
||||
`/kling/tasks`,
|
||||
{
|
||||
action: 'retrieve_batch',
|
||||
...(filter.ids
|
||||
? {
|
||||
ids: filter.ids
|
||||
}
|
||||
: {}),
|
||||
...(filter.applicationId
|
||||
? {
|
||||
application_id: filter.applicationId
|
||||
}
|
||||
: {}),
|
||||
...(filter.userId
|
||||
? {
|
||||
user_id: filter.userId
|
||||
}
|
||||
: {}),
|
||||
...(filter.type
|
||||
? {
|
||||
type: filter.type
|
||||
}
|
||||
: {}),
|
||||
...(filter.limit !== undefined
|
||||
? {
|
||||
limit: filter.limit
|
||||
}
|
||||
: {}),
|
||||
...(filter.offset !== undefined
|
||||
? {
|
||||
offset: filter.offset
|
||||
}
|
||||
: {}),
|
||||
...(filter.createdAtMax !== undefined
|
||||
? {
|
||||
created_at_max: filter.createdAtMax
|
||||
}
|
||||
: {}),
|
||||
...(filter.createdAtMin !== undefined
|
||||
? {
|
||||
created_at_min: filter.createdAtMin
|
||||
}
|
||||
: {})
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
accept: 'application/json',
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'x-record-exempt': 'true'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async generate(
|
||||
data: IKlingGenerateRequest,
|
||||
options: {
|
||||
token: string;
|
||||
}
|
||||
): Promise<AxiosResponse<IKlingGenerateResponse>> {
|
||||
return await axios.post('/kling/videos', data, {
|
||||
headers: {
|
||||
authorization: `Bearer ${options.token}`,
|
||||
'content-type': 'application/json',
|
||||
accept: 'application/x-ndjson'
|
||||
},
|
||||
baseURL: BASE_URL_API
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const klingOperator = new KlingOperator();
|
||||
Reference in new issue
Block a user