cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/ai-gateway/custom-providers.ts
350lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import * as Core from '../../core'; |
| 5 | import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination'; |
| 6 | |
| 7 | export class CustomProviders extends APIResource { |
| 8 | /** |
| 9 | * Creates a new AI Gateway. |
| 10 | * |
| 11 | * @example |
| 12 | * ```ts |
| 13 | * const customProvider = |
| 14 | * await client.aiGateway.customProviders.create({ |
| 15 | * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', |
| 16 | * base_url: 'https://example.com', |
| 17 | * name: 'name', |
| 18 | * slug: 'slug', |
| 19 | * }); |
| 20 | * ``` |
| 21 | */ |
| 22 | create( |
| 23 | params: CustomProviderCreateParams, |
| 24 | options?: Core.RequestOptions, |
| 25 | ): Core.APIPromise<CustomProviderCreateResponse> { |
| 26 | const { account_id, ...body } = params; |
| 27 | return ( |
| 28 | this._client.post(`/accounts/${account_id}/ai-gateway/custom-providers`, { |
| 29 | body, |
| 30 | ...options, |
| 31 | }) as Core.APIPromise<{ result: CustomProviderCreateResponse }> |
| 32 | )._thenUnwrap((obj) => obj.result); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Lists all AI Gateway evaluator types configured for the account. |
| 37 | * |
| 38 | * @example |
| 39 | * ```ts |
| 40 | * // Automatically fetches more pages as needed. |
| 41 | * for await (const customProviderListResponse of client.aiGateway.customProviders.list( |
| 42 | * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, |
| 43 | * )) { |
| 44 | * // ... |
| 45 | * } |
| 46 | * ``` |
| 47 | */ |
| 48 | list( |
| 49 | params: CustomProviderListParams, |
| 50 | options?: Core.RequestOptions, |
| 51 | ): Core.PagePromise<CustomProviderListResponsesV4PagePaginationArray, CustomProviderListResponse> { |
| 52 | const { account_id, ...query } = params; |
| 53 | return this._client.getAPIList( |
| 54 | `/accounts/${account_id}/ai-gateway/custom-providers`, |
| 55 | CustomProviderListResponsesV4PagePaginationArray, |
| 56 | { query, ...options }, |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Deletes an AI Gateway dataset. |
| 62 | * |
| 63 | * @example |
| 64 | * ```ts |
| 65 | * const customProvider = |
| 66 | * await client.aiGateway.customProviders.delete( |
| 67 | * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', |
| 68 | * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, |
| 69 | * ); |
| 70 | * ``` |
| 71 | */ |
| 72 | delete( |
| 73 | id: string, |
| 74 | params: CustomProviderDeleteParams, |
| 75 | options?: Core.RequestOptions, |
| 76 | ): Core.APIPromise<CustomProviderDeleteResponse> { |
| 77 | const { account_id } = params; |
| 78 | return ( |
| 79 | this._client.delete( |
| 80 | `/accounts/${account_id}/ai-gateway/custom-providers/${id}`, |
| 81 | options, |
| 82 | ) as Core.APIPromise<{ result: CustomProviderDeleteResponse }> |
| 83 | )._thenUnwrap((obj) => obj.result); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Retrieves details for a specific AI Gateway dataset. |
| 88 | * |
| 89 | * @example |
| 90 | * ```ts |
| 91 | * const customProvider = |
| 92 | * await client.aiGateway.customProviders.get( |
| 93 | * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', |
| 94 | * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, |
| 95 | * ); |
| 96 | * ``` |
| 97 | */ |
| 98 | get( |
| 99 | id: string, |
| 100 | params: CustomProviderGetParams, |
| 101 | options?: Core.RequestOptions, |
| 102 | ): Core.APIPromise<CustomProviderGetResponse> { |
| 103 | const { account_id } = params; |
| 104 | return ( |
| 105 | this._client.get( |
| 106 | `/accounts/${account_id}/ai-gateway/custom-providers/${id}`, |
| 107 | options, |
| 108 | ) as Core.APIPromise<{ result: CustomProviderGetResponse }> |
| 109 | )._thenUnwrap((obj) => obj.result); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | export class CustomProviderListResponsesV4PagePaginationArray extends V4PagePaginationArray<CustomProviderListResponse> {} |
| 114 | |
| 115 | export interface CustomProviderCreateResponse { |
| 116 | id: string; |
| 117 | |
| 118 | base_url: string; |
| 119 | |
| 120 | created_at: string; |
| 121 | |
| 122 | modified_at: string; |
| 123 | |
| 124 | name: string; |
| 125 | |
| 126 | slug: string; |
| 127 | |
| 128 | beta?: boolean; |
| 129 | |
| 130 | curl_example?: string; |
| 131 | |
| 132 | description?: string; |
| 133 | |
| 134 | enable?: boolean; |
| 135 | |
| 136 | headers?: string; |
| 137 | |
| 138 | js_example?: string; |
| 139 | |
| 140 | link?: string; |
| 141 | |
| 142 | logo?: string; |
| 143 | |
| 144 | position?: number; |
| 145 | } |
| 146 | |
| 147 | export interface CustomProviderListResponse { |
| 148 | id: string; |
| 149 | |
| 150 | base_url: string; |
| 151 | |
| 152 | created_at: string; |
| 153 | |
| 154 | modified_at: string; |
| 155 | |
| 156 | name: string; |
| 157 | |
| 158 | slug: string; |
| 159 | |
| 160 | beta?: boolean; |
| 161 | |
| 162 | curl_example?: string; |
| 163 | |
| 164 | description?: string; |
| 165 | |
| 166 | enable?: boolean; |
| 167 | |
| 168 | headers?: string; |
| 169 | |
| 170 | js_example?: string; |
| 171 | |
| 172 | link?: string; |
| 173 | |
| 174 | logo?: string; |
| 175 | |
| 176 | position?: number; |
| 177 | } |
| 178 | |
| 179 | export interface CustomProviderDeleteResponse { |
| 180 | id: string; |
| 181 | |
| 182 | base_url: string; |
| 183 | |
| 184 | created_at: string; |
| 185 | |
| 186 | modified_at: string; |
| 187 | |
| 188 | name: string; |
| 189 | |
| 190 | slug: string; |
| 191 | |
| 192 | beta?: boolean; |
| 193 | |
| 194 | curl_example?: string; |
| 195 | |
| 196 | description?: string; |
| 197 | |
| 198 | enable?: boolean; |
| 199 | |
| 200 | headers?: string; |
| 201 | |
| 202 | js_example?: string; |
| 203 | |
| 204 | link?: string; |
| 205 | |
| 206 | logo?: string; |
| 207 | |
| 208 | position?: number; |
| 209 | } |
| 210 | |
| 211 | export interface CustomProviderGetResponse { |
| 212 | id: string; |
| 213 | |
| 214 | base_url: string; |
| 215 | |
| 216 | created_at: string; |
| 217 | |
| 218 | modified_at: string; |
| 219 | |
| 220 | name: string; |
| 221 | |
| 222 | slug: string; |
| 223 | |
| 224 | beta?: boolean; |
| 225 | |
| 226 | curl_example?: string; |
| 227 | |
| 228 | description?: string; |
| 229 | |
| 230 | enable?: boolean; |
| 231 | |
| 232 | headers?: string; |
| 233 | |
| 234 | js_example?: string; |
| 235 | |
| 236 | link?: string; |
| 237 | |
| 238 | logo?: string; |
| 239 | |
| 240 | position?: number; |
| 241 | } |
| 242 | |
| 243 | export interface CustomProviderCreateParams { |
| 244 | /** |
| 245 | * Path param |
| 246 | */ |
| 247 | account_id: string; |
| 248 | |
| 249 | /** |
| 250 | * Body param |
| 251 | */ |
| 252 | base_url: string; |
| 253 | |
| 254 | /** |
| 255 | * Body param |
| 256 | */ |
| 257 | name: string; |
| 258 | |
| 259 | /** |
| 260 | * Body param |
| 261 | */ |
| 262 | slug: string; |
| 263 | |
| 264 | /** |
| 265 | * Body param |
| 266 | */ |
| 267 | beta?: boolean; |
| 268 | |
| 269 | /** |
| 270 | * Body param |
| 271 | */ |
| 272 | curl_example?: string; |
| 273 | |
| 274 | /** |
| 275 | * Body param |
| 276 | */ |
| 277 | description?: string; |
| 278 | |
| 279 | /** |
| 280 | * Body param |
| 281 | */ |
| 282 | enable?: boolean; |
| 283 | |
| 284 | /** |
| 285 | * Body param |
| 286 | */ |
| 287 | headers?: string; |
| 288 | |
| 289 | /** |
| 290 | * Body param |
| 291 | */ |
| 292 | js_example?: string; |
| 293 | |
| 294 | /** |
| 295 | * Body param |
| 296 | */ |
| 297 | link?: string; |
| 298 | |
| 299 | /** |
| 300 | * Body param |
| 301 | */ |
| 302 | position?: number; |
| 303 | } |
| 304 | |
| 305 | export interface CustomProviderListParams extends V4PagePaginationArrayParams { |
| 306 | /** |
| 307 | * Path param |
| 308 | */ |
| 309 | account_id: string; |
| 310 | |
| 311 | /** |
| 312 | * Query param |
| 313 | */ |
| 314 | beta?: boolean; |
| 315 | |
| 316 | /** |
| 317 | * Query param |
| 318 | */ |
| 319 | enable?: boolean; |
| 320 | |
| 321 | /** |
| 322 | * Query param: Search by id, name, slug |
| 323 | */ |
| 324 | search?: string; |
| 325 | } |
| 326 | |
| 327 | export interface CustomProviderDeleteParams { |
| 328 | account_id: string; |
| 329 | } |
| 330 | |
| 331 | export interface CustomProviderGetParams { |
| 332 | account_id: string; |
| 333 | } |
| 334 | |
| 335 | CustomProviders.CustomProviderListResponsesV4PagePaginationArray = |
| 336 | CustomProviderListResponsesV4PagePaginationArray; |
| 337 | |
| 338 | export declare namespace CustomProviders { |
| 339 | export { |
| 340 | type CustomProviderCreateResponse as CustomProviderCreateResponse, |
| 341 | type CustomProviderListResponse as CustomProviderListResponse, |
| 342 | type CustomProviderDeleteResponse as CustomProviderDeleteResponse, |
| 343 | type CustomProviderGetResponse as CustomProviderGetResponse, |
| 344 | CustomProviderListResponsesV4PagePaginationArray as CustomProviderListResponsesV4PagePaginationArray, |
| 345 | type CustomProviderCreateParams as CustomProviderCreateParams, |
| 346 | type CustomProviderListParams as CustomProviderListParams, |
| 347 | type CustomProviderDeleteParams as CustomProviderDeleteParams, |
| 348 | type CustomProviderGetParams as CustomProviderGetParams, |
| 349 | }; |
| 350 | } |
| 351 | |