cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/ai/ai.ts
1064lines · 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 * as AuthorsAPI from './authors'; |
| 6 | import { AuthorListParams, AuthorListResponse, AuthorListResponsesSinglePage, Authors } from './authors'; |
| 7 | import * as TasksAPI from './tasks'; |
| 8 | import { TaskListParams, TaskListResponse, TaskListResponsesSinglePage, Tasks } from './tasks'; |
| 9 | import * as FinetunesAPI from './finetunes/finetunes'; |
| 10 | import { |
| 11 | FinetuneCreateParams, |
| 12 | FinetuneCreateResponse, |
| 13 | FinetuneListParams, |
| 14 | FinetuneListResponse, |
| 15 | Finetunes, |
| 16 | } from './finetunes/finetunes'; |
| 17 | import * as ModelsAPI from './models/models'; |
| 18 | import { |
| 19 | ModelListParams, |
| 20 | ModelListResponse, |
| 21 | ModelListResponsesV4PagePaginationArray, |
| 22 | Models, |
| 23 | } from './models/models'; |
| 24 | |
| 25 | export class AI extends APIResource { |
| 26 | finetunes: FinetunesAPI.Finetunes = new FinetunesAPI.Finetunes(this._client); |
| 27 | authors: AuthorsAPI.Authors = new AuthorsAPI.Authors(this._client); |
| 28 | tasks: TasksAPI.Tasks = new TasksAPI.Tasks(this._client); |
| 29 | models: ModelsAPI.Models = new ModelsAPI.Models(this._client); |
| 30 | |
| 31 | /** |
| 32 | * This endpoint provides users with the capability to run specific AI models |
| 33 | * on-demand. |
| 34 | * |
| 35 | * By submitting the required input data, users can receive real-time predictions |
| 36 | * or results generated by the chosen AI model. The endpoint supports various AI |
| 37 | * model types, ensuring flexibility and adaptability for diverse use cases. |
| 38 | * |
| 39 | * Model specific inputs available in |
| 40 | * [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). |
| 41 | */ |
| 42 | run(modelName: string, params: AIRunParams, options?: Core.RequestOptions): Core.APIPromise<AIRunResponse> { |
| 43 | const { account_id, ...body } = params; |
| 44 | return ( |
| 45 | this._client.post(`/accounts/${account_id}/ai/run/${modelName}`, { |
| 46 | body, |
| 47 | ...options, |
| 48 | }) as Core.APIPromise<{ result: AIRunResponse }> |
| 49 | )._thenUnwrap((obj) => obj.result); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * An array of classification results for the input text |
| 55 | */ |
| 56 | export type AIRunResponse = |
| 57 | | Array<AIRunResponse.TextClassification> |
| 58 | | Core.Uploadable |
| 59 | | AIRunResponse.Audio |
| 60 | | AIRunResponse.TextEmbeddings |
| 61 | | AIRunResponse.AutomaticSpeechRecognition |
| 62 | | Array<AIRunResponse.ImageClassification> |
| 63 | | Array<AIRunResponse.ObjectDetection> |
| 64 | | AIRunResponse.UnionMember7 |
| 65 | | AIRunResponse.Translation |
| 66 | | AIRunResponse.Summarization |
| 67 | | AIRunResponse.ImageToText |
| 68 | | AIRunResponse.ImageTextToText; |
| 69 | |
| 70 | export namespace AIRunResponse { |
| 71 | export interface TextClassification { |
| 72 | /** |
| 73 | * The classification label assigned to the text (e.g., 'POSITIVE' or 'NEGATIVE') |
| 74 | */ |
| 75 | label?: string; |
| 76 | |
| 77 | /** |
| 78 | * Confidence score indicating the likelihood that the text belongs to the |
| 79 | * specified label |
| 80 | */ |
| 81 | score?: number; |
| 82 | } |
| 83 | |
| 84 | export interface Audio { |
| 85 | /** |
| 86 | * The generated audio in MP3 format, base64-encoded |
| 87 | */ |
| 88 | audio?: string; |
| 89 | } |
| 90 | |
| 91 | export interface TextEmbeddings { |
| 92 | /** |
| 93 | * Embeddings of the requested text values |
| 94 | */ |
| 95 | data?: Array<Array<number>>; |
| 96 | |
| 97 | shape?: Array<number>; |
| 98 | } |
| 99 | |
| 100 | export interface AutomaticSpeechRecognition { |
| 101 | /** |
| 102 | * The transcription |
| 103 | */ |
| 104 | text: string; |
| 105 | |
| 106 | vtt?: string; |
| 107 | |
| 108 | word_count?: number; |
| 109 | |
| 110 | words?: Array<AutomaticSpeechRecognition.Word>; |
| 111 | } |
| 112 | |
| 113 | export namespace AutomaticSpeechRecognition { |
| 114 | export interface Word { |
| 115 | /** |
| 116 | * The ending second when the word completes |
| 117 | */ |
| 118 | end?: number; |
| 119 | |
| 120 | /** |
| 121 | * The second this word begins in the recording |
| 122 | */ |
| 123 | start?: number; |
| 124 | |
| 125 | word?: string; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | export interface ImageClassification { |
| 130 | /** |
| 131 | * The predicted category or class for the input image based on analysis |
| 132 | */ |
| 133 | label?: string; |
| 134 | |
| 135 | /** |
| 136 | * A confidence value, between 0 and 1, indicating how certain the model is about |
| 137 | * the predicted label |
| 138 | */ |
| 139 | score?: number; |
| 140 | } |
| 141 | |
| 142 | export interface ObjectDetection { |
| 143 | /** |
| 144 | * Coordinates defining the bounding box around the detected object |
| 145 | */ |
| 146 | box?: ObjectDetection.Box; |
| 147 | |
| 148 | /** |
| 149 | * The class label or name of the detected object |
| 150 | */ |
| 151 | label?: string; |
| 152 | |
| 153 | /** |
| 154 | * Confidence score indicating the likelihood that the detection is correct |
| 155 | */ |
| 156 | score?: number; |
| 157 | } |
| 158 | |
| 159 | export namespace ObjectDetection { |
| 160 | /** |
| 161 | * Coordinates defining the bounding box around the detected object |
| 162 | */ |
| 163 | export interface Box { |
| 164 | /** |
| 165 | * The x-coordinate of the bottom-right corner of the bounding box |
| 166 | */ |
| 167 | xmax?: number; |
| 168 | |
| 169 | /** |
| 170 | * The x-coordinate of the top-left corner of the bounding box |
| 171 | */ |
| 172 | xmin?: number; |
| 173 | |
| 174 | /** |
| 175 | * The y-coordinate of the bottom-right corner of the bounding box |
| 176 | */ |
| 177 | ymax?: number; |
| 178 | |
| 179 | /** |
| 180 | * The y-coordinate of the top-left corner of the bounding box |
| 181 | */ |
| 182 | ymin?: number; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | export interface UnionMember7 { |
| 187 | /** |
| 188 | * The generated text response from the model |
| 189 | */ |
| 190 | response: string; |
| 191 | |
| 192 | /** |
| 193 | * An array of tool calls requests made during the response generation |
| 194 | */ |
| 195 | tool_calls?: Array<UnionMember7.ToolCall>; |
| 196 | |
| 197 | /** |
| 198 | * Usage statistics for the inference request |
| 199 | */ |
| 200 | usage?: UnionMember7.Usage; |
| 201 | } |
| 202 | |
| 203 | export namespace UnionMember7 { |
| 204 | export interface ToolCall { |
| 205 | /** |
| 206 | * The arguments passed to be passed to the tool call request |
| 207 | */ |
| 208 | arguments?: unknown; |
| 209 | |
| 210 | /** |
| 211 | * The name of the tool to be called |
| 212 | */ |
| 213 | name?: string; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Usage statistics for the inference request |
| 218 | */ |
| 219 | export interface Usage { |
| 220 | /** |
| 221 | * Total number of tokens in output |
| 222 | */ |
| 223 | completion_tokens?: number; |
| 224 | |
| 225 | /** |
| 226 | * Total number of tokens in input |
| 227 | */ |
| 228 | prompt_tokens?: number; |
| 229 | |
| 230 | /** |
| 231 | * Total number of input and output tokens |
| 232 | */ |
| 233 | total_tokens?: number; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | export interface Translation { |
| 238 | /** |
| 239 | * The translated text in the target language |
| 240 | */ |
| 241 | translated_text?: string; |
| 242 | } |
| 243 | |
| 244 | export interface Summarization { |
| 245 | /** |
| 246 | * The summarized version of the input text |
| 247 | */ |
| 248 | summary?: string; |
| 249 | } |
| 250 | |
| 251 | export interface ImageToText { |
| 252 | description?: string; |
| 253 | } |
| 254 | |
| 255 | export interface ImageTextToText { |
| 256 | description?: string; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | export type AIRunParams = |
| 261 | | AIRunParams.TextClassification |
| 262 | | AIRunParams.TextToImage |
| 263 | | AIRunParams.TextToSpeech |
| 264 | | AIRunParams.TextEmbeddings |
| 265 | | AIRunParams.AutomaticSpeechRecognition |
| 266 | | AIRunParams.ImageClassification |
| 267 | | AIRunParams.ObjectDetection |
| 268 | | AIRunParams.Prompt |
| 269 | | AIRunParams.Messages |
| 270 | | AIRunParams.Translation |
| 271 | | AIRunParams.Summarization |
| 272 | | AIRunParams.ImageToText |
| 273 | | AIRunParams.Variant12 |
| 274 | | AIRunParams.Variant13; |
| 275 | |
| 276 | export declare namespace AIRunParams { |
| 277 | export interface TextClassification { |
| 278 | /** |
| 279 | * Path param: |
| 280 | */ |
| 281 | account_id: string; |
| 282 | |
| 283 | /** |
| 284 | * Body param: The text that you want to classify |
| 285 | */ |
| 286 | text: string; |
| 287 | } |
| 288 | |
| 289 | export interface TextToImage { |
| 290 | /** |
| 291 | * Path param: |
| 292 | */ |
| 293 | account_id: string; |
| 294 | |
| 295 | /** |
| 296 | * Body param: A text description of the image you want to generate |
| 297 | */ |
| 298 | prompt: string; |
| 299 | |
| 300 | /** |
| 301 | * Body param: Controls how closely the generated image should adhere to the |
| 302 | * prompt; higher values make the image more aligned with the prompt |
| 303 | */ |
| 304 | guidance?: number; |
| 305 | |
| 306 | /** |
| 307 | * Body param: The height of the generated image in pixels |
| 308 | */ |
| 309 | height?: number; |
| 310 | |
| 311 | /** |
| 312 | * Body param: For use with img2img tasks. An array of integers that represent the |
| 313 | * image data constrained to 8-bit unsigned integer values |
| 314 | */ |
| 315 | image?: Array<number>; |
| 316 | |
| 317 | /** |
| 318 | * Body param: For use with img2img tasks. A base64-encoded string of the input |
| 319 | * image |
| 320 | */ |
| 321 | image_b64?: string; |
| 322 | |
| 323 | /** |
| 324 | * Body param: An array representing An array of integers that represent mask image |
| 325 | * data for inpainting constrained to 8-bit unsigned integer values |
| 326 | */ |
| 327 | mask?: Array<number>; |
| 328 | |
| 329 | /** |
| 330 | * Body param: Text describing elements to avoid in the generated image |
| 331 | */ |
| 332 | negative_prompt?: string; |
| 333 | |
| 334 | /** |
| 335 | * Body param: The number of diffusion steps; higher values can improve quality but |
| 336 | * take longer |
| 337 | */ |
| 338 | num_steps?: number; |
| 339 | |
| 340 | /** |
| 341 | * Body param: Random seed for reproducibility of the image generation |
| 342 | */ |
| 343 | seed?: number; |
| 344 | |
| 345 | /** |
| 346 | * Body param: A value between 0 and 1 indicating how strongly to apply the |
| 347 | * transformation during img2img tasks; lower values make the output closer to the |
| 348 | * input image |
| 349 | */ |
| 350 | strength?: number; |
| 351 | |
| 352 | /** |
| 353 | * Body param: The width of the generated image in pixels |
| 354 | */ |
| 355 | width?: number; |
| 356 | } |
| 357 | |
| 358 | export interface TextToSpeech { |
| 359 | /** |
| 360 | * Path param: |
| 361 | */ |
| 362 | account_id: string; |
| 363 | |
| 364 | /** |
| 365 | * Body param: A text description of the audio you want to generate |
| 366 | */ |
| 367 | prompt: string; |
| 368 | |
| 369 | /** |
| 370 | * Body param: The speech language (e.g., 'en' for English, 'fr' for French). |
| 371 | * Defaults to 'en' if not specified |
| 372 | */ |
| 373 | lang?: string; |
| 374 | } |
| 375 | |
| 376 | export interface TextEmbeddings { |
| 377 | /** |
| 378 | * Path param: |
| 379 | */ |
| 380 | account_id: string; |
| 381 | |
| 382 | /** |
| 383 | * Body param: The text to embed |
| 384 | */ |
| 385 | text: string | Array<string>; |
| 386 | } |
| 387 | |
| 388 | export interface AutomaticSpeechRecognition { |
| 389 | /** |
| 390 | * Path param: |
| 391 | */ |
| 392 | account_id: string; |
| 393 | |
| 394 | /** |
| 395 | * Body param: An array of integers that represent the audio data constrained to |
| 396 | * 8-bit unsigned integer values |
| 397 | */ |
| 398 | audio: Array<number>; |
| 399 | |
| 400 | /** |
| 401 | * Body param: The language of the recorded audio |
| 402 | */ |
| 403 | source_lang?: string; |
| 404 | |
| 405 | /** |
| 406 | * Body param: The language to translate the transcription into. Currently only |
| 407 | * English is supported. |
| 408 | */ |
| 409 | target_lang?: string; |
| 410 | } |
| 411 | |
| 412 | export interface ImageClassification { |
| 413 | /** |
| 414 | * Path param: |
| 415 | */ |
| 416 | account_id: string; |
| 417 | |
| 418 | /** |
| 419 | * Body param: An array of integers that represent the image data constrained to |
| 420 | * 8-bit unsigned integer values |
| 421 | */ |
| 422 | image: Array<number>; |
| 423 | } |
| 424 | |
| 425 | export interface ObjectDetection { |
| 426 | /** |
| 427 | * Path param: |
| 428 | */ |
| 429 | account_id: string; |
| 430 | |
| 431 | /** |
| 432 | * Body param: An array of integers that represent the image data constrained to |
| 433 | * 8-bit unsigned integer values |
| 434 | */ |
| 435 | image?: Array<number>; |
| 436 | } |
| 437 | |
| 438 | export interface Prompt { |
| 439 | /** |
| 440 | * Path param: |
| 441 | */ |
| 442 | account_id: string; |
| 443 | |
| 444 | /** |
| 445 | * Body param: The input text prompt for the model to generate a response. |
| 446 | */ |
| 447 | prompt: string; |
| 448 | |
| 449 | /** |
| 450 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 451 | * verbatim. |
| 452 | */ |
| 453 | frequency_penalty?: number; |
| 454 | |
| 455 | /** |
| 456 | * Body param: Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base |
| 457 | * model. |
| 458 | */ |
| 459 | lora?: string; |
| 460 | |
| 461 | /** |
| 462 | * Body param: The maximum number of tokens to generate in the response. |
| 463 | */ |
| 464 | max_tokens?: number; |
| 465 | |
| 466 | /** |
| 467 | * Body param: Increases the likelihood of the model introducing new topics. |
| 468 | */ |
| 469 | presence_penalty?: number; |
| 470 | |
| 471 | /** |
| 472 | * Body param: If true, a chat template is not applied and you must adhere to the |
| 473 | * specific model's expected formatting. |
| 474 | */ |
| 475 | raw?: boolean; |
| 476 | |
| 477 | /** |
| 478 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 479 | */ |
| 480 | repetition_penalty?: number; |
| 481 | |
| 482 | /** |
| 483 | * Body param: |
| 484 | */ |
| 485 | response_format?: Prompt.ResponseFormat; |
| 486 | |
| 487 | /** |
| 488 | * Body param: Random seed for reproducibility of the generation. |
| 489 | */ |
| 490 | seed?: number; |
| 491 | |
| 492 | /** |
| 493 | * Body param: If true, the response will be streamed back incrementally using SSE, |
| 494 | * Server Sent Events. |
| 495 | */ |
| 496 | stream?: boolean; |
| 497 | |
| 498 | /** |
| 499 | * Body param: Controls the randomness of the output; higher values produce more |
| 500 | * random results. |
| 501 | */ |
| 502 | temperature?: number; |
| 503 | |
| 504 | /** |
| 505 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 506 | * values make responses more focused; higher values introduce more variety and |
| 507 | * potential surprises. |
| 508 | */ |
| 509 | top_k?: number; |
| 510 | |
| 511 | /** |
| 512 | * Body param: Adjusts the creativity of the AI's responses by controlling how many |
| 513 | * possible words it considers. Lower values make outputs more predictable; higher |
| 514 | * values allow for more varied and creative responses. |
| 515 | */ |
| 516 | top_p?: number; |
| 517 | } |
| 518 | |
| 519 | export namespace Prompt { |
| 520 | export interface ResponseFormat { |
| 521 | json_schema?: unknown; |
| 522 | |
| 523 | type?: 'json_object' | 'json_schema'; |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | export interface Messages { |
| 528 | /** |
| 529 | * Path param: |
| 530 | */ |
| 531 | account_id: string; |
| 532 | |
| 533 | /** |
| 534 | * Body param: An array of message objects representing the conversation history. |
| 535 | */ |
| 536 | messages: Array<Messages.Message>; |
| 537 | |
| 538 | /** |
| 539 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 540 | * verbatim. |
| 541 | */ |
| 542 | frequency_penalty?: number; |
| 543 | |
| 544 | /** |
| 545 | * Body param: |
| 546 | */ |
| 547 | functions?: Array<Messages.Function>; |
| 548 | |
| 549 | /** |
| 550 | * Body param: The maximum number of tokens to generate in the response. |
| 551 | */ |
| 552 | max_tokens?: number; |
| 553 | |
| 554 | /** |
| 555 | * Body param: Increases the likelihood of the model introducing new topics. |
| 556 | */ |
| 557 | presence_penalty?: number; |
| 558 | |
| 559 | /** |
| 560 | * Body param: If true, a chat template is not applied and you must adhere to the |
| 561 | * specific model's expected formatting. |
| 562 | */ |
| 563 | raw?: boolean; |
| 564 | |
| 565 | /** |
| 566 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 567 | */ |
| 568 | repetition_penalty?: number; |
| 569 | |
| 570 | /** |
| 571 | * Body param: |
| 572 | */ |
| 573 | response_format?: Messages.ResponseFormat; |
| 574 | |
| 575 | /** |
| 576 | * Body param: Random seed for reproducibility of the generation. |
| 577 | */ |
| 578 | seed?: number; |
| 579 | |
| 580 | /** |
| 581 | * Body param: If true, the response will be streamed back incrementally using SSE, |
| 582 | * Server Sent Events. |
| 583 | */ |
| 584 | stream?: boolean; |
| 585 | |
| 586 | /** |
| 587 | * Body param: Controls the randomness of the output; higher values produce more |
| 588 | * random results. |
| 589 | */ |
| 590 | temperature?: number; |
| 591 | |
| 592 | /** |
| 593 | * Body param: A list of tools available for the assistant to use. |
| 594 | */ |
| 595 | tools?: Array<Messages.UnionMember0 | Messages.UnionMember1>; |
| 596 | |
| 597 | /** |
| 598 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 599 | * values make responses more focused; higher values introduce more variety and |
| 600 | * potential surprises. |
| 601 | */ |
| 602 | top_k?: number; |
| 603 | |
| 604 | /** |
| 605 | * Body param: Adjusts the creativity of the AI's responses by controlling how many |
| 606 | * possible words it considers. Lower values make outputs more predictable; higher |
| 607 | * values allow for more varied and creative responses. |
| 608 | */ |
| 609 | top_p?: number; |
| 610 | } |
| 611 | |
| 612 | export namespace Messages { |
| 613 | export interface Message { |
| 614 | /** |
| 615 | * The content of the message as a string. |
| 616 | */ |
| 617 | content: string; |
| 618 | |
| 619 | /** |
| 620 | * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). |
| 621 | */ |
| 622 | role: string; |
| 623 | } |
| 624 | |
| 625 | export interface Function { |
| 626 | code: string; |
| 627 | |
| 628 | name: string; |
| 629 | } |
| 630 | |
| 631 | export interface ResponseFormat { |
| 632 | json_schema?: unknown; |
| 633 | |
| 634 | type?: 'json_object' | 'json_schema'; |
| 635 | } |
| 636 | |
| 637 | export interface UnionMember0 { |
| 638 | /** |
| 639 | * A brief description of what the tool does. |
| 640 | */ |
| 641 | description: string; |
| 642 | |
| 643 | /** |
| 644 | * The name of the tool. More descriptive the better. |
| 645 | */ |
| 646 | name: string; |
| 647 | |
| 648 | /** |
| 649 | * Schema defining the parameters accepted by the tool. |
| 650 | */ |
| 651 | parameters: UnionMember0.Parameters; |
| 652 | } |
| 653 | |
| 654 | export namespace UnionMember0 { |
| 655 | /** |
| 656 | * Schema defining the parameters accepted by the tool. |
| 657 | */ |
| 658 | export interface Parameters { |
| 659 | /** |
| 660 | * Definitions of each parameter. |
| 661 | */ |
| 662 | properties: Record<string, Parameters.Properties>; |
| 663 | |
| 664 | /** |
| 665 | * The type of the parameters object (usually 'object'). |
| 666 | */ |
| 667 | type: string; |
| 668 | |
| 669 | /** |
| 670 | * List of required parameter names. |
| 671 | */ |
| 672 | required?: Array<string>; |
| 673 | } |
| 674 | |
| 675 | export namespace Parameters { |
| 676 | export interface Properties { |
| 677 | /** |
| 678 | * A description of the expected parameter. |
| 679 | */ |
| 680 | description: string; |
| 681 | |
| 682 | /** |
| 683 | * The data type of the parameter. |
| 684 | */ |
| 685 | type: string; |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | export interface UnionMember1 { |
| 691 | /** |
| 692 | * Details of the function tool. |
| 693 | */ |
| 694 | function: UnionMember1.Function; |
| 695 | |
| 696 | /** |
| 697 | * Specifies the type of tool (e.g., 'function'). |
| 698 | */ |
| 699 | type: string; |
| 700 | } |
| 701 | |
| 702 | export namespace UnionMember1 { |
| 703 | /** |
| 704 | * Details of the function tool. |
| 705 | */ |
| 706 | export interface Function { |
| 707 | /** |
| 708 | * A brief description of what the function does. |
| 709 | */ |
| 710 | description: string; |
| 711 | |
| 712 | /** |
| 713 | * The name of the function. |
| 714 | */ |
| 715 | name: string; |
| 716 | |
| 717 | /** |
| 718 | * Schema defining the parameters accepted by the function. |
| 719 | */ |
| 720 | parameters: Function.Parameters; |
| 721 | } |
| 722 | |
| 723 | export namespace Function { |
| 724 | /** |
| 725 | * Schema defining the parameters accepted by the function. |
| 726 | */ |
| 727 | export interface Parameters { |
| 728 | /** |
| 729 | * Definitions of each parameter. |
| 730 | */ |
| 731 | properties: Record<string, Parameters.Properties>; |
| 732 | |
| 733 | /** |
| 734 | * The type of the parameters object (usually 'object'). |
| 735 | */ |
| 736 | type: string; |
| 737 | |
| 738 | /** |
| 739 | * List of required parameter names. |
| 740 | */ |
| 741 | required?: Array<string>; |
| 742 | } |
| 743 | |
| 744 | export namespace Parameters { |
| 745 | export interface Properties { |
| 746 | /** |
| 747 | * A description of the expected parameter. |
| 748 | */ |
| 749 | description: string; |
| 750 | |
| 751 | /** |
| 752 | * The data type of the parameter. |
| 753 | */ |
| 754 | type: string; |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | export interface Translation { |
| 762 | /** |
| 763 | * Path param: |
| 764 | */ |
| 765 | account_id: string; |
| 766 | |
| 767 | /** |
| 768 | * Body param: The language code to translate the text into (e.g., 'es' for |
| 769 | * Spanish) |
| 770 | */ |
| 771 | target_lang: string; |
| 772 | |
| 773 | /** |
| 774 | * Body param: The text to be translated |
| 775 | */ |
| 776 | text: string; |
| 777 | |
| 778 | /** |
| 779 | * Body param: The language code of the source text (e.g., 'en' for English). |
| 780 | * Defaults to 'en' if not specified |
| 781 | */ |
| 782 | source_lang?: string; |
| 783 | } |
| 784 | |
| 785 | export interface Summarization { |
| 786 | /** |
| 787 | * Path param: |
| 788 | */ |
| 789 | account_id: string; |
| 790 | |
| 791 | /** |
| 792 | * Body param: The text that you want the model to summarize |
| 793 | */ |
| 794 | input_text: string; |
| 795 | |
| 796 | /** |
| 797 | * Body param: The maximum length of the generated summary in tokens |
| 798 | */ |
| 799 | max_length?: number; |
| 800 | } |
| 801 | |
| 802 | export interface ImageToText { |
| 803 | /** |
| 804 | * Path param: |
| 805 | */ |
| 806 | account_id: string; |
| 807 | |
| 808 | /** |
| 809 | * Body param: An array of integers that represent the image data constrained to |
| 810 | * 8-bit unsigned integer values |
| 811 | */ |
| 812 | image: Array<number>; |
| 813 | |
| 814 | /** |
| 815 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 816 | * verbatim. |
| 817 | */ |
| 818 | frequency_penalty?: number; |
| 819 | |
| 820 | /** |
| 821 | * Body param: The maximum number of tokens to generate in the response. |
| 822 | */ |
| 823 | max_tokens?: number; |
| 824 | |
| 825 | /** |
| 826 | * Body param: Increases the likelihood of the model introducing new topics. |
| 827 | */ |
| 828 | presence_penalty?: number; |
| 829 | |
| 830 | /** |
| 831 | * Body param: The input text prompt for the model to generate a response. |
| 832 | */ |
| 833 | prompt?: string; |
| 834 | |
| 835 | /** |
| 836 | * Body param: If true, a chat template is not applied and you must adhere to the |
| 837 | * specific model's expected formatting. |
| 838 | */ |
| 839 | raw?: boolean; |
| 840 | |
| 841 | /** |
| 842 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 843 | */ |
| 844 | repetition_penalty?: number; |
| 845 | |
| 846 | /** |
| 847 | * Body param: Random seed for reproducibility of the generation. |
| 848 | */ |
| 849 | seed?: number; |
| 850 | |
| 851 | /** |
| 852 | * Body param: Controls the randomness of the output; higher values produce more |
| 853 | * random results. |
| 854 | */ |
| 855 | temperature?: number; |
| 856 | |
| 857 | /** |
| 858 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 859 | * values make responses more focused; higher values introduce more variety and |
| 860 | * potential surprises. |
| 861 | */ |
| 862 | top_k?: number; |
| 863 | |
| 864 | /** |
| 865 | * Body param: Controls the creativity of the AI's responses by adjusting how many |
| 866 | * possible words it considers. Lower values make outputs more predictable; higher |
| 867 | * values allow for more varied and creative responses. |
| 868 | */ |
| 869 | top_p?: number; |
| 870 | } |
| 871 | |
| 872 | export interface Variant12 { |
| 873 | /** |
| 874 | * Path param: |
| 875 | */ |
| 876 | account_id: string; |
| 877 | |
| 878 | /** |
| 879 | * Body param: Image in base64 encoded format. |
| 880 | */ |
| 881 | image: string; |
| 882 | |
| 883 | /** |
| 884 | * Body param: The input text prompt for the model to generate a response. |
| 885 | */ |
| 886 | prompt: string; |
| 887 | |
| 888 | /** |
| 889 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 890 | * verbatim. |
| 891 | */ |
| 892 | frequency_penalty?: number; |
| 893 | |
| 894 | /** |
| 895 | * Body param: Whether to ignore the EOS token and continue generating tokens after |
| 896 | * the EOS token is generated. |
| 897 | */ |
| 898 | ignore_eos?: boolean; |
| 899 | |
| 900 | /** |
| 901 | * Body param: The maximum number of tokens to generate in the response. |
| 902 | */ |
| 903 | max_tokens?: number; |
| 904 | |
| 905 | /** |
| 906 | * Body param: Increases the likelihood of the model introducing new topics. |
| 907 | */ |
| 908 | presence_penalty?: number; |
| 909 | |
| 910 | /** |
| 911 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 912 | */ |
| 913 | repetition_penalty?: number; |
| 914 | |
| 915 | /** |
| 916 | * Body param: Random seed for reproducibility of the generation. |
| 917 | */ |
| 918 | seed?: number; |
| 919 | |
| 920 | /** |
| 921 | * Body param: Controls the randomness of the output; higher values produce more |
| 922 | * random results. |
| 923 | */ |
| 924 | temperature?: number; |
| 925 | |
| 926 | /** |
| 927 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 928 | * values make responses more focused; higher values introduce more variety and |
| 929 | * potential surprises. |
| 930 | */ |
| 931 | top_k?: number; |
| 932 | |
| 933 | /** |
| 934 | * Body param: Controls the creativity of the AI's responses by adjusting how many |
| 935 | * possible words it considers. Lower values make outputs more predictable; higher |
| 936 | * values allow for more varied and creative responses. |
| 937 | */ |
| 938 | top_p?: number; |
| 939 | } |
| 940 | |
| 941 | export interface Variant13 { |
| 942 | /** |
| 943 | * Path param: |
| 944 | */ |
| 945 | account_id: string; |
| 946 | |
| 947 | /** |
| 948 | * Body param: Image in base64 encoded format. |
| 949 | */ |
| 950 | image: string; |
| 951 | |
| 952 | /** |
| 953 | * Body param: An array of message objects representing the conversation history. |
| 954 | */ |
| 955 | messages: Array<Variant13.Message>; |
| 956 | |
| 957 | /** |
| 958 | * Body param: Decreases the likelihood of the model repeating the same lines |
| 959 | * verbatim. |
| 960 | */ |
| 961 | frequency_penalty?: number; |
| 962 | |
| 963 | /** |
| 964 | * Body param: Whether to ignore the EOS token and continue generating tokens after |
| 965 | * the EOS token is generated. |
| 966 | */ |
| 967 | ignore_eos?: boolean; |
| 968 | |
| 969 | /** |
| 970 | * Body param: The maximum number of tokens to generate in the response. |
| 971 | */ |
| 972 | max_tokens?: number; |
| 973 | |
| 974 | /** |
| 975 | * Body param: Increases the likelihood of the model introducing new topics. |
| 976 | */ |
| 977 | presence_penalty?: number; |
| 978 | |
| 979 | /** |
| 980 | * Body param: Penalty for repeated tokens; higher values discourage repetition. |
| 981 | */ |
| 982 | repetition_penalty?: number; |
| 983 | |
| 984 | /** |
| 985 | * Body param: Random seed for reproducibility of the generation. |
| 986 | */ |
| 987 | seed?: number; |
| 988 | |
| 989 | /** |
| 990 | * Body param: Controls the randomness of the output; higher values produce more |
| 991 | * random results. |
| 992 | */ |
| 993 | temperature?: number; |
| 994 | |
| 995 | /** |
| 996 | * Body param: Limits the AI to choose from the top 'k' most probable words. Lower |
| 997 | * values make responses more focused; higher values introduce more variety and |
| 998 | * potential surprises. |
| 999 | */ |
| 1000 | top_k?: number; |
| 1001 | |
| 1002 | /** |
| 1003 | * Body param: Controls the creativity of the AI's responses by adjusting how many |
| 1004 | * possible words it considers. Lower values make outputs more predictable; higher |
| 1005 | * values allow for more varied and creative responses. |
| 1006 | */ |
| 1007 | top_p?: number; |
| 1008 | } |
| 1009 | |
| 1010 | export namespace Variant13 { |
| 1011 | export interface Message { |
| 1012 | /** |
| 1013 | * The content of the message as a string. |
| 1014 | */ |
| 1015 | content: string; |
| 1016 | |
| 1017 | /** |
| 1018 | * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). |
| 1019 | */ |
| 1020 | role: string; |
| 1021 | } |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | AI.Finetunes = Finetunes; |
| 1026 | AI.Authors = Authors; |
| 1027 | AI.AuthorListResponsesSinglePage = AuthorListResponsesSinglePage; |
| 1028 | AI.Tasks = Tasks; |
| 1029 | AI.TaskListResponsesSinglePage = TaskListResponsesSinglePage; |
| 1030 | AI.Models = Models; |
| 1031 | AI.ModelListResponsesV4PagePaginationArray = ModelListResponsesV4PagePaginationArray; |
| 1032 | |
| 1033 | export declare namespace AI { |
| 1034 | export { type AIRunResponse as AIRunResponse, type AIRunParams as AIRunParams }; |
| 1035 | |
| 1036 | export { |
| 1037 | Finetunes as Finetunes, |
| 1038 | type FinetuneCreateResponse as FinetuneCreateResponse, |
| 1039 | type FinetuneListResponse as FinetuneListResponse, |
| 1040 | type FinetuneCreateParams as FinetuneCreateParams, |
| 1041 | type FinetuneListParams as FinetuneListParams, |
| 1042 | }; |
| 1043 | |
| 1044 | export { |
| 1045 | Authors as Authors, |
| 1046 | type AuthorListResponse as AuthorListResponse, |
| 1047 | AuthorListResponsesSinglePage as AuthorListResponsesSinglePage, |
| 1048 | type AuthorListParams as AuthorListParams, |
| 1049 | }; |
| 1050 | |
| 1051 | export { |
| 1052 | Tasks as Tasks, |
| 1053 | type TaskListResponse as TaskListResponse, |
| 1054 | TaskListResponsesSinglePage as TaskListResponsesSinglePage, |
| 1055 | type TaskListParams as TaskListParams, |
| 1056 | }; |
| 1057 | |
| 1058 | export { |
| 1059 | Models as Models, |
| 1060 | type ModelListResponse as ModelListResponse, |
| 1061 | ModelListResponsesV4PagePaginationArray as ModelListResponsesV4PagePaginationArray, |
| 1062 | type ModelListParams as ModelListParams, |
| 1063 | }; |
| 1064 | } |