clapper / src /lib /hf /getGradioApiInfo.ts
jbilcke-hf's picture
jbilcke-hf HF staff
add linter and prettifier
c1f12bf
raw
history blame
No virus
489 Bytes
import { Client } from '@gradio/client'
import { GradioApiInfo } from './types'
import { parseHuggingFaceHubId } from './parseHuggingFaceHubId'
export async function getGradioApiInfo({
url,
apiKey,
}: {
url: string
apiKey?: string
}): Promise<GradioApiInfo> {
const { ownerAndId } = parseHuggingFaceHubId(url, 'spaces')
const app = await Client.connect(ownerAndId, {
hf_token: apiKey as any,
})
const apiInfo: GradioApiInfo = await app.view_api()
return apiInfo
}