@@ -6,12 +6,15 @@ async function fetchModelsCop(modelName) {
66 ) ;
77}
88
9- function buildCodeSamplesByBody ( body ) {
9+ function buildCodeSamplesByBody (
10+ body ,
11+ url = 'https://api.aimlapi.com/v2/video/generations'
12+ ) {
1013 return [
1114 {
1215 lang : 'JavaScript' ,
1316 source : `async function main() {
14- const response = await fetch('https://api.aimlapi.com/v2/video/generations ', {
17+ const response = await fetch('${ url } ', {
1518 method: 'POST',
1619 headers: {
1720 'Authorization': 'Bearer <YOUR_API_KEY>',
@@ -31,7 +34,7 @@ main();`,
3134 source : `import requests
3235
3336response = requests.post(
34- "https://api.aimlapi.com/v2/video/generations ",
37+ "${ url } ",
3538 headers={
3639 "Content-Type": "application/json",
3740 "Authorization": "Bearer <YOUR_API_KEY>",
@@ -46,15 +49,15 @@ print(data)`,
4649 lang : 'cURL' ,
4750 source : `curl -L \\
4851 --request POST \\
49- --url 'https://api.aimlapi.com/v2/video/generations ' \\
52+ --url '${ url } ' \\
5053 --header 'Authorization: Bearer <YOUR_API_KEY>' \\
5154 --header 'Content-Type: application/json' \\
5255 --data '${ body . replace ( / ' / g, "\\'" ) . replace ( / \n / g, '\n ' ) } '` ,
5356 } ,
5457 {
5558 lang : 'HTTP' ,
5659 source : `POST / HTTP/1.1
57- Host: test.com
60+ Host: ${ url }
5861Authorization: Bearer <YOUR_API_KEY>
5962Content-Type: application/json
6063Accept: */*
@@ -570,13 +573,18 @@ Accept: */*
570573 }
571574 const jsonBody = JSON . stringify ( customParams , null , 2 ) ;
572575
573- return buildCodeSamplesByBody ( jsonBody ) ;
576+ return buildCodeSamplesByBody (
577+ jsonBody ,
578+ 'https://api.aimlapi.com/v2/generate/audio'
579+ ) ;
574580 } else if ( model . category === 'speech-models' ) {
575581 const requiredModelParams = schema ?. required || [ ] ;
576582 const customParams = {
577583 model : modelName ,
578584 } ;
585+ let url = 'https://api.aimlapi.com/v1/tts' ;
579586 if ( path . includes ( 'stt' ) ) {
587+ url = 'https://api.aimlapi.com/v1/stt/create' ;
580588 Object . assign ( customParams , {
581589 url : 'https://audio-samples.github.io/samples/mp3/blizzard_primed/sample-0.mp3' ,
582590 } ) ;
@@ -603,7 +611,7 @@ Accept: */*
603611 }
604612 const jsonBody = JSON . stringify ( customParams , null , 2 ) ;
605613
606- return buildCodeSamplesByBody ( jsonBody ) ;
614+ return buildCodeSamplesByBody ( jsonBody , url ) ;
607615 }
608616}
609617
0 commit comments