1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1ad351a4-ef18-417e-8511-ea6dd0bce5b9",e._sentryDebugIdIdentifier="sentry-dbid-1ad351a4-ef18-417e-8511-ea6dd0bce5b9")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7270],{75618:function(e,t,a){Promise.resolve().then(a.bind(a,535))},535:function(e,t,a){"use strict";a.d(t,{ApiDocsContent:function(){return f}});var s=a(37821),r=a(58078),i=a(41331),l=a(23745),n=a(28651),o=a(38114),c=a(17459),d=a(97647);function p(){let e={GET:"text-green-700",POST:"text-blue-700"};return(0,s.jsx)("aside",{className:"hidden lg:block",children:(0,s.jsx)("nav",{className:"sticky top-24 space-y-6",children:[{title:"Overview",items:[{href:"#authentication",label:"Authentication"},{href:"#base-url",label:"Base URL"}]},{title:"Playlists",items:[{href:"#list-playlists",label:"List playlists",method:"GET"},{href:"#get-playlist",label:"Get playlist",method:"GET"},{href:"#create-playlist",label:"Create playlist",method:"POST"}]},{title:"Tracks",items:[{href:"#list-tracks",label:"List tracks",method:"GET"},{href:"#create-track",label:"Create track",method:"POST"},{href:"#convert-track",label:"Convert track",method:"POST"}]},{title:"Reference",items:[{href:"#voices",label:"Available Voices"},{href:"#errors",label:"Errors"},{href:"#rate-limits",label:"Rate Limits"}]}].map(t=>(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2",children:t.title}),(0,s.jsx)("ul",{className:"space-y-1",children:t.items.map(t=>(0,s.jsx)("li",{children:(0,s.jsxs)("a",{href:t.href,className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 py-0.5",children:["method"in t&&t.method&&(0,s.jsx)("span",{className:`text-[10px] font-mono font-bold ${e[t.method]||""}`,children:t.method}),t.label]})},t.href))})]},t.title))})})}function h(e){let{id:t,title:a,children:r}=e;return(0,s.jsxs)("section",{id:t,className:"mb-12 scroll-mt-24",children:[(0,s.jsx)("h2",{className:"text-2xl font-semibold mb-4",children:a}),r]})}function u(e){let{id:t,method:a,path:r,description:i,children:l}=e;return(0,s.jsxs)("div",{id:t,className:"mb-8 p-4 border rounded-lg scroll-mt-24",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,s.jsx)("span",{className:`px-2 py-0.5 rounded text-xs font-mono font-bold ${{GET:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",POST:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"}[a]||""}`,children:a}),(0,s.jsx)("code",{className:"text-sm",children:r})]}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),l]})}function m(e){let{title:t,params:a}=e;return(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)("h4",{className:"font-medium mb-2",children:t}),(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b",children:[(0,s.jsx)("th",{className:"text-left py-2 pr-4",children:"Parameter"}),(0,s.jsx)("th",{className:"text-left py-2 pr-4",children:"Type"}),(0,s.jsx)("th",{className:"text-left py-2 pr-4",children:"Required"}),(0,s.jsx)("th",{className:"text-left py-2",children:"Description"})]})}),(0,s.jsx)("tbody",{children:a.map(e=>(0,s.jsxs)("tr",{className:"border-b",children:[(0,s.jsx)("td",{className:"py-2 pr-4",children:(0,s.jsx)("code",{children:e.name})}),(0,s.jsx)("td",{className:"py-2 pr-4 text-muted-foreground",children:e.type}),(0,s.jsx)("td",{className:"py-2 pr-4",children:e.required?(0,s.jsx)("span",{className:"text-red-600 text-xs font-medium",children:"Required"}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"Optional"})}),(0,s.jsx)("td",{className:"py-2",children:e.description})]},e.name))})]})]})}function x(e){let{tabs:t}=e,[a,l]=(0,r.useState)(0),[n,o]=(0,r.useState)(!1);return(0,s.jsxs)("div",{className:"mt-3 border rounded-lg overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b bg-gray-50",children:[(0,s.jsx)("div",{className:"flex",children:t.map((e,t)=>(0,s.jsx)("button",{onClick:()=>l(t),className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t===a?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-700"}`,children:e.label},e.label))}),(0,s.jsx)("button",{onClick:function(){navigator.clipboard.writeText(t[a].code),o(!0),setTimeout(()=>
1o(!1),2e3)},className:"mr-2 px-2 py-1 rounded text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-200 transition-colors",children:n?"Copied!":"Copy"})]}),(0,s.jsx)(i.Z,{language:t[a].language,style:d.Z,className:"!m-0 !p-4 !rounded-none overflow-x-auto text-sm",children:t[a].code})]})}function y(e){let{children:t,language:a="bash"}=e,[l,n]=(0,r.useState)(!1);return(0,s.jsxs)("div",{className:"relative mt-2 group",children:[(0,s.jsx)("button",{onClick:function(){navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),2e3)},className:"absolute right-2 top-2 px-2 py-1 rounded text-xs bg-gray-200 hover:bg-gray-300 text-gray-700 opacity-0 group-hover:opacity-100 transition-opacity",children:l?"Copied!":"Copy"}),(0,s.jsx)(i.Z,{language:a,style:d.Z,className:"!p-4 rounded-lg overflow-x-auto text-sm !bg-gray-50",children:t})]})}function g(e){let{baseUrl:t,apiKey:a}=e;return(0,s.jsxs)(h,{id:"playlists",title:"Playlists",children:[(0,s.jsxs)(u,{id:"list-playlists",method:"GET",path:"/playlists",description:"List all your playlists",children:[(0,s.jsx)(x,{tabs:[{label:"cURL",language:"bash",code:`curl ${t}/api/v1/playlists \\ 2 -H "Authorization: Bearer ${a}"`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("${t}/api/v1/playlists", { 3 headers: { "Authorization": "Bearer ${a}" }, 4}) 5const data = await res.json() 6console.log(data.playlists)`},{label:"Python",language:"python",code:`import requests 7 8res = requests.get("${t}/api/v1/playlists", 9 headers={"Authorization": "Bearer ${a}"}) 10print(res.json()["playlists"])`}]}),(0,s.jsx)("h4",{className:"font-medium mt-4 mb-2",children:"Response"}),(0,s.jsx)(y,{language:"json",children:`{ 11 "playlists": [ 12 { 13 "id": 1, 14 "name": "My Playlist", 15 "voice": "echo", 16 "trackCount": 3, 17 "createdAt": "2026-01-01T00:00:00.000Z" 18 } 19 ] 20}`})]}),(0,s.jsxs)(u,{id:"get-playlist",method:"GET",path:"/playlists/:id",description:"Get a playlist with all its tracks",children:[(0,s.jsx)(x,{tabs:[{label:"cURL",language:"bash",code:`curl ${t}/api/v1/playlists/{playlistId} \\ 21 -H "Authorization: Bearer ${a}"`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("${t}/api/v1/playlists/{playlistId}", { 22 headers: { "Authorization": "Bearer ${a}" }, 23}) 24const data = await res.json() 25console.log(data.playlist)`},{label:"Python",language:"python",code:`import requests 26 27res = requests.get("${t}/api/v1/playlists/{playlistId}", 28 headers={"Authorization": "Bearer ${a}"}) 29print(res.json()["playlist"])`}]}),(0,s.jsx)("h4",{className:"font-medium mt-4 mb-2",children:"Response"}),(0,s.jsx)(y,{language:"json",children:`{ 30 "playlist": { 31 "id": 1, 32 "name": "My Playlist", 33 "voice": "echo", 34 "trackCount": 2, 35 "createdAt": "2026-01-01T00:00:00.000Z", 36 "tracks": [ 37 { 38 "id": 42, 39 "title": "Chapter 1", 40 "contentLength": 1234, 41 "order": 1, 42 "status": "stitched", 43 "audioUrl": "https://...", 44 "createdAt": "2026-01-01T00:00:00.000Z" 45 } 46 ] 47 } 48}`})]}),(0,s.jsxs)(u,{id:"create-playlist",method:"POST",path:"/playlists",description:"Create a new playlist",children:[(0,s.jsx)(m,{title:"Request Body",params:[{name:"name",type:"string",required:!0,description:"Name of the playlist"},{name:"voice",type:"string",required:!1,description:"Default voice for tracks. Defaults to your account voice"}]}),(0,s.jsx)(x,{tabs:[{label:"cURL",language:"bash",code:`curl -X POST ${t}/api/v1/playlists \\ 49 -H "Authorization: Bearer ${a}" \\ 50 -H "Content-Type: application/json" \\ 51 -d '{"name": "My Playlist"}'`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("${t}/api/v1/playlists", { 52 method: "POST", 53 headers: { 54 "Authorization": "Bearer ${a}", 55 "Content-Type": "application/json", 56 }, 57 body: JSON.stringify({ name: "My Playlist" }), 58}) 59const data = await res.json() 60console.log(data.playlist)`},{label:"Python",language:"python",code:`import requests 61 62res = requests.post("${t}/api/v1/playlists", 63 headers={"Authorization": "Bearer ${a}", "Content-Type": "application/json"}, 64 json={"name": "My Playlist"}) 65print(res.json()["playlist"])`}]}
65),(0,s.jsx)("h4",{className:"font-medium mt-4 mb-2",children:"Response"}),(0,s.jsx)(y,{language:"json",children:`{ 66 "playlist": { 67 "id": 1, 68 "name": "My Playlist", 69 "voice": "echo", 70 "createdAt": "2026-01-01T00:00:00.000Z" 71 } 72}`})]})]})}function j(){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h,{id:"voices",title:"Available Voices",children:(0,s.jsxs)("p",{children:["We support a wide range of voices from OpenAI and Azure. Browse and preview all available voices on the"," ",(0,s.jsx)("a",{href:"/voices",className:"underline",children:"Voices page"}),". Pass the voice name in the convert request body."]})}),(0,s.jsxs)(h,{id:"errors",title:"Errors",children:[(0,s.jsxs)("p",{children:["All errors return JSON with an ",(0,s.jsx)("code",{children:"error"})," field:"]}),(0,s.jsx)(y,{language:"json",children:`{ 73 "error": "Invalid API key" 74}`}),(0,s.jsxs)("table",{className:"mt-4 w-full text-sm",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b",children:[(0,s.jsx)("th",{className:"text-left py-2 pr-4",children:"Status"}),(0,s.jsx)("th",{className:"text-left py-2",children:"Description"})]})}),(0,s.jsxs)("tbody",{children:[(0,s.jsxs)("tr",{className:"border-b",children:[(0,s.jsx)("td",{className:"py-2 pr-4",children:(0,s.jsx)("code",{children:"401"})}),(0,s.jsx)("td",{className:"py-2",children:"Missing or invalid API key"})]}),(0,s.jsxs)("tr",{className:"border-b",children:[(0,s.jsx)("td",{className:"py-2 pr-4",children:(0,s.jsx)("code",{children:"400"})}),(0,s.jsx)("td",{className:"py-2",children:"Invalid request body"})]}),(0,s.jsxs)("tr",{className:"border-b",children:[(0,s.jsx)("td",{className:"py-2 pr-4",children:(0,s.jsx)("code",{children:"404"})}),(0,s.jsx)("td",{className:"py-2",children:"Playlist or track not found"})]}),(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{className:"py-2 pr-4",children:(0,s.jsx)("code",{children:"500"})}),(0,s.jsx)("td",{className:"py-2",children:"Server error"})]})]})]})]}),(0,s.jsx)(h,{id:"rate-limits",title:"Rate Limits",children:(0,s.jsxs)("p",{children:["API access is limited by your credit balance. Each character of text converted costs one credit. Check your remaining credits on the"," ",(0,s.jsx)("a",{href:"/settings",className:"underline",children:"Settings page"}),"."]})})]})}function b(e){let{baseUrl:t,apiKey:a}=e;return(0,s.jsxs)(h,{id:"tracks",title:"Tracks",children:[(0,s.jsxs)(u,{id:"list-tracks",method:"GET",path:"/playlists/:id/tracks",description:"List all tracks in a playlist",children:[(0,s.jsx)(x,{tabs:[{label:"cURL",language:"bash",code:`curl ${t}/api/v1/playlists/{playlistId}/tracks \\ 75 -H "Authorization: Bearer ${a}"`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("${t}/api/v1/playlists/{playlistId}/tracks", { 76 headers: { "Authorization": "Bearer ${a}" }, 77}) 78const data = await res.json() 79console.log(data.tracks)`},{label:"Python",language:"python",code:`import requests 80 81res = requests.get("${t}/api/v1/playlists/{playlistId}/tracks", 82 headers={"Authorization": "Bearer ${a}"}) 83print(res.json()["tracks"])`}]}),(0,s.jsx)("h4",{className:"font-medium mt-4 mb-2",children:"Response"}),(0,s.jsx)(y,{language:"json",children:`{ 84 "tracks": [ 85 { 86 "id": 42, 87 "title": "Chapter 1", 88 "contentLength": 1234, 89 "order": 1, 90 "status": "stitched", 91 "audioUrl": "https://...", 92 "createdAt": "2026-01-01T00:00:00.000Z" 93 } 94 ] 95}`})]}),(0,s.jsxs)(u,{id:"create-track",method:"POST",path:"/playlists/:id/tracks",description:"Add a track to a playlist",children:[(0,s.jsx)(m,{title:"Request Body",params:[{name:"title",type:"string",required:!1,description:'Track title. Defaults to page title (if url) or "Untitled Track"'},{name:"content",type:"string",required:!1,description:"The text content to convert to audio. Required if url is not provided"},{name:"url",type:"string",required:!1,description:"URL to fetch content from. Extracts clean text using Readability. Required if content is not provided"}]}),(0,s.jsx)(x,{tabs:[{label:"cURL",language:"bash",code:`# With text content 96curl -X POST ${t}/api/v1/playlists/{playlistId}/tracks \\ 97 -H "Authorization: Bearer ${a}" \\ 98 -H "Content-Type: application/json" \\ 99 -d '{"title": "Chapter 1", "content": "The text content to convert to audio..."}' 100 101# With URL (extracts clean text automatically) 102curl -X POST ${t}/api/v1/playlists/{playlistId}/tracks \\ 103 -H "Authorization: Bearer ${a}" \\ 104 -H "Content-Type: application/json" \\ 105 -d '{"url": "https://paulgraham.com/start.html"}'`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("${t}/api/v1/playlists/{playlistId}/tracks", { 106 method: "POST", 107 headers: { 108 "Authorization": "Bearer ${a}", 109 "Content-Type": "application/json", 110 }, 111 body: JSON.stringify({ 112 title: "Chapter 1", 113 content: "The text content to convert to audio...", 114 }), 115}) 116const data = await res.json() 117console.log(data.track)`},{label:"Python",language:"python",code:`import requests 118 119res = requests.post("${t}/api/v1/playlists/{playlistId}/tracks", 120 headers={"Authorization": "Bearer ${a}", "Content-Type": "application/json"}, 121 json={"title": "Chapter 1", "content": "The text content to convert to audio..."}) 122print(res.json()["track"])`}]}
122),(0,s.jsx)("h4",{className:"font-medium mt-4 mb-2",children:"Response"}),(0,s.jsx)(y,{language:"json",children:`{ 123 "track": { 124 "id": 42, 125 "title": "Chapter 1", 126 "contentLength": 1234, 127 "order": 1, 128 "createdAt": "2026-01-01T00:00:00.000Z" 129 } 130}`})]}),(0,s.jsxs)(u,{id:"convert-track",method:"POST",path:"/playlists/:id/tracks/:trackId/convert",description:"Convert a track to audio (Server-Sent Events)",children:[(0,s.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This endpoint returns a stream of Server-Sent Events (SSE) reporting progress as each chunk is converted and then stitched together."}),(0,s.jsx)(m,{title:"Request Body (optional)",params:[{name:"voice",type:"string",required:!1,description:"Voice to use. Defaults to the playlist voice"}]}),(0,s.jsx)(x,{tabs:[{label:"cURL",language:"bash",code:`curl -N -X POST ${t}/api/v1/playlists/{playlistId}/tracks/{trackId}/convert \\ 131 -H "Authorization: Bearer ${a}" \\ 132 -H "Content-Type: application/json"`},{label:"JavaScript",language:"javascript",code:`const res = await fetch( 133 "${t}/api/v1/playlists/{playlistId}/tracks/{trackId}/convert", 134 { 135 method: "POST", 136 headers: { "Authorization": "Bearer ${a}" }, 137 } 138) 139 140const reader = res.body.getReader() 141const decoder = new TextDecoder() 142let buffer = "" 143 144while (true) { 145 const { done, value } = await reader.read() 146 if (done) break 147 buffer += decoder.decode(value, { stream: true }) 148 149 const lines = buffer.split("\\n") 150 buffer = lines.pop() 151 152 for (const line of lines) { 153 if (line.startsWith("data: ")) { 154 const event = JSON.parse(line.slice(6)) 155 console.log(event) 156 if (event.type === "complete") { 157 console.log("Audio URL:", event.audioUrl) 158 } 159 } 160 } 161}`},{label:"Python",language:"python",code:`import requests 162import json 163 164res = requests.post( 165 "${t}/api/v1/playlists/{playlistId}/tracks/{trackId}/convert", 166 headers={"Authorization": "Bearer ${a}"}, 167 stream=True) 168 169for line in res.iter_lines(): 170 if line: 171 line = line.decode("utf-8") 172 if line.startswith("data: "): 173 event = json.loads(line[6:]) 174 print(event) 175 if event["type"] == "complete": 176 print("Audio URL:", event["audioUrl"])`}]}),(0,s.jsx)("h4",{className:"font-medium mt-4 mb-2",children:"SSE Events"}),(0,s.jsx)(y,{language:"json",children:`data: {"type":"started","trackId":42,"voice":"echo"} 177 178data: {"type":"chunking","totalChunks":5} 179 180data: {"type":"progress","chunk":1,"total":5,"message":"Converted chunk 1 of 5"} 181 182data: {"type":"stitching","message":"Combining audio chunks..."} 183 184data: {"type":"complete","audioUrl":"https://...","duration":120}`})]})]})}function f(e){let{baseUrl:t}=e,a=function(){let[e,t]=(0,r.useState)("aw_your_api_key_here");return(0,r.useEffect)(()=>{fetch("/api/user/api-key").then(e=>e.ok?e.json():null).then(e=>{e?.apiKey&&t(e.apiKey)}).catch(()=>{})},[]),e}();return(0,s.jsxs)("div",{className:"mx-auto w-full max-w-5xl px-6 py-16 lg:grid lg:grid-cols-[200px_1fr] lg:gap-10",children:[(0,s.jsx)(p,{}),(0,s.jsxs)("main",{className:"min-w-0 max-w-full overflow-x-hidden",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mb-2",children:[(0,s.jsx)("h1",{className:"text-3xl sm:text-4xl font-bold",children:"API Documentation"}),(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-semibold bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",children:"Beta"})]}),(0,s.jsx)("p",{className:"text-lg text-muted-foreground mb-12",children:"Convert text to audiobook-quality audio programmatically. This API is in beta â endpoints and response shapes may change."}),(0,s.jsxs)(h,{id:"authentication",title:"Authentication",children:[(0,s.jsxs)("p",{children:["All API requests require an API key. Generate one from your"," ",(0,s.jsx)("a",{href:"/settings",className:"underline",children:"Settings page"}),"."]}),(0,s.jsxs)("p",{className:"mt-2",children:["Include your key in the ",(0,s.jsx)("code",{children:"Authorization"})," header:"]}),(0,s.jsx)(y,{language:"bash",children:`Authorization: Bearer ${a}`})]}),(0,s.jsx)(h,{id:"base-url",title:"Base URL",children:(0,s.jsx)(y,{language:"bash",children:`${t}/api/v1`})}),(0,s.jsx)(g,{baseUrl:t,apiKey:a}),(0,s.jsx)(b,{baseUrl:t,apiKey:a}),(0,s.jsx)(j,{})]})]})}i.Z.registerLanguage("bash",l.Z),i.Z.registerLanguage("javascript",n.Z),i.Z.registerLanguage("json",o.Z),i.Z.registerLanguage("python",c.Z)}}
184,function(e){e.O(0,[440,1975,7115,370,1744],function(){return e(e.s=75618)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.