| 9 | * @param apiKey Your Bytez API key |
| 10 | */ |
| 11 | export default class Bytez { |
| 12 | constructor(apiKey: string, dev = false, browser?: boolean) { |
| 13 | this.#client = new Client(apiKey, dev, browser); |
| 14 | } |
| 15 | #client: Client; |
| 16 | list = { |
| 17 | /** Lists available models, and provides basic information about each one, such as RAM required */ |
| 18 | models: (options?: ListModels): Promise<Response> => |
| 19 | this.#client.request( |
| 20 | `list/models${options?.task ? `?task=${options.task}` : ""}${ |
| 21 | options?.modelId ? `?modelId=${options.modelId}` : "" |
| 22 | }` |
| 23 | ) as Promise<Response>, |
| 24 | /** List available tasks */ |
| 25 | tasks: (): Promise<Response> => |
| 26 | this.#client.request("list/tasks") as Promise<Response> |
| 27 | }; |
| 28 | /** |
| 29 | * Get a model - allows you to run closed and open source models |
| 30 | * @param modelId The modelId, for example `openai-community/gpt2` |
| 31 | * @param providerKey Optional: Closed-source model provider's API key (e.g. OpenAI key) |
| 32 | */ |
| 33 | model = (modelId: string, providerKey?: string): Model => |
| 34 | new Model(modelId, this, this.#client, providerKey); |
| 35 | } |