Spaces:
Running
Running
Download sdk/node/src/index.ts from shivamkr00902/data2: direct link, hf CLI and curl.
- Browser
- Download file 564 Bytes
-
https://huggingface.co/spaces/shivamkr00902/data2/resolve/main/sdk/node/src/index.ts
- Command line
-
hf download hf://spaces/shivamkr00902/data2/sdk/node/src/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/shivamkr00902/data2/resolve/main/sdk/node/src/index.ts
564 Bytes
| import OpenAI from 'openai'; | |
| import type { ClientOptions } from 'openai'; | |
| export type GatewayOptions = ClientOptions; | |
| export class Gateway extends OpenAI { | |
| constructor(options: GatewayOptions = {}) { | |
| const baseURL = options.baseURL ?? process.env.GATEWAY_BASE_URL; | |
| const apiKey = options.apiKey ?? process.env.GATEWAY_API_KEY; | |
| if (!baseURL || !apiKey) throw new Error('Set GATEWAY_BASE_URL and GATEWAY_API_KEY or pass both explicitly.'); | |
| super({ ...options, baseURL, apiKey, maxRetries: options.maxRetries ?? 0 }); | |
| } | |
| } | |
| export default Gateway; | |