-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.ts
More file actions
45 lines (39 loc) · 1.4 KB
/
example.ts
File metadata and controls
45 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Example usage of the tensors-client
*/
import { Configuration, DatabaseApi, DownloadApi, GalleryApi, SearchApi } from './src'
// Configure the client
// Default basePath is https://tensors-api.saiden.dev (can be omitted)
const config = new Configuration({
apiKey: 'YOUR_API_KEY', // Set TENSORS_API_KEY or replace with your key
})
// Create API instances
const search = new SearchApi(config)
const database = new DatabaseApi(config)
const gallery = new GalleryApi(config)
const download = new DownloadApi(config)
async function main() {
// Search models
console.log('=== Search Models ===')
const searchResults = await search.searchModelsApiSearchGet({
types: 'LORA',
baseModels: 'Illustrious',
tag: 'anime',
limit: 5,
})
console.log('Found:', (searchResults as any).items?.length, 'models')
;(searchResults as any).items?.slice(0, 3).forEach((m: any) => {
console.log(` - ${m.id}: ${m.name}`)
})
// Get database stats
console.log('\n=== Database Stats ===')
const stats = await database.getStatsApiDbStatsGet()
console.log('Models:', stats.models)
console.log('Versions:', stats.model_versions)
console.log('Local files:', stats.local_files)
// List gallery images
console.log('\n=== Gallery ===')
const galleryStats = await gallery.galleryStatsApiImagesStatsSummaryGet()
console.log('Total images:', galleryStats.total_images)
}
main().catch(console.error)