## Execute AI model `client.ai.run(stringmodelName, AIRunParamsparams, RequestOptionsoptions?): AIRunResponse` **post** `/accounts/{account_id}/ai/run/{model_name}` This endpoint provides users with the capability to run specific AI models on-demand. By submitting the required input data, users can receive real-time predictions or results generated by the chosen AI model. The endpoint supports various AI model types, ensuring flexibility and adaptability for diverse use cases. Model specific inputs available in [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). ### Parameters - `modelName: string` - `AIRunParams = TextClassification | TextToImage | TextToSpeech | 12 more` - `AIRunParamsBase` - `TextClassification extends AIRunParamsBase` - `TextToImage extends AIRunParamsBase` - `TextToSpeech extends AIRunParamsBase` - `TextEmbeddings extends AIRunParamsBase` - `AutomaticSpeechRecognition extends AIRunParamsBase` - `ImageClassification extends AIRunParamsBase` - `ObjectDetection extends AIRunParamsBase` - `Prompt extends AIRunParamsBase` - `Messages extends AIRunParamsBase` - `Translation extends AIRunParamsBase` - `Summarization extends AIRunParamsBase` - `ImageToText extends AIRunParamsBase` - `Variant12 extends AIRunParamsBase` - `Variant13 extends AIRunParamsBase` - `MultimodalEmbeddings extends AIRunParamsBase` ### Returns - `AIRunResponse = Array | Uploadable | Audio | 12 more` An array of classification results for the input text - `Array` - `label?: string` The classification label assigned to the text (e.g., 'POSITIVE' or 'NEGATIVE') - `score?: number` Confidence score indicating the likelihood that the text belongs to the specified label - `Uploadable` - `Audio` - `audio?: string` The generated audio in MP3 format, base64-encoded - `Uploadable` - `TextEmbeddings` - `data?: Array>` Embeddings of the requested text values - `shape?: Array` - `AutomaticSpeechRecognition` - `text: string` The transcription - `vtt?: string` - `word_count?: number` - `words?: Array` - `end?: number` The ending second when the word completes - `start?: number` The second this word begins in the recording - `word?: string` - `Array` - `label?: string` The predicted category or class for the input image based on analysis - `score?: number` A confidence value, between 0 and 1, indicating how certain the model is about the predicted label - `Array` - `box?: Box` Coordinates defining the bounding box around the detected object - `xmax?: number` The x-coordinate of the bottom-right corner of the bounding box - `xmin?: number` The x-coordinate of the top-left corner of the bounding box - `ymax?: number` The y-coordinate of the bottom-right corner of the bounding box - `ymin?: number` The y-coordinate of the top-left corner of the bounding box - `label?: string` The class label or name of the detected object - `score?: number` Confidence score indicating the likelihood that the detection is correct - `UnionMember8` - `response: string` The generated text response from the model - `tool_calls?: Array` An array of tool calls requests made during the response generation - `arguments?: unknown` The arguments passed to be passed to the tool call request - `name?: string` The name of the tool to be called - `usage?: Usage` Usage statistics for the inference request - `completion_tokens?: number` Total number of tokens in output - `prompt_tokens?: number` Total number of tokens in input - `total_tokens?: number` Total number of input and output tokens - `Uploadable` - `Translation` - `translated_text?: string` The translated text in the target language - `Summarization` - `summary?: string` The summarized version of the input text - `ImageToText` - `description?: string` - `ImageTextToText` - `description?: string` - `MultimodalEmbeddings` - `data?: Array>` - `shape?: Array` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.ai.run('model_name', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', text: 'x', }); console.log(response); ``` #### Response ```json { "result": [ { "label": "label", "score": 0 } ] } ```