## Execute AI model `client.AI.Run(ctx, modelName, params) (*AIRunResponseUnion, error)` **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` - `params AIRunParams` - `AccountID param.Field[string]` Path param - `Text param.Field[string]` Body param: The text that you want to classify ### Returns - `type AIRunResponseUnion interface{…}` An array of classification results for the input text - `type AIRunResponseTextClassification []AIRunResponseTextClassificationItem` An array of classification results for the input text - `Label string` The classification label assigned to the text (e.g., 'POSITIVE' or 'NEGATIVE') - `Score float64` Confidence score indicating the likelihood that the text belongs to the specified label - `UnionString` - `type AIRunResponseAudio struct{…}` - `Audio string` The generated audio in MP3 format, base64-encoded - `UnionString` - `type AIRunResponseTextEmbeddings struct{…}` - `Data [][]float64` Embeddings of the requested text values - `Shape []float64` - `type AIRunResponseAutomaticSpeechRecognition struct{…}` - `Text string` The transcription - `Vtt string` - `WordCount float64` - `Words []AIRunResponseAutomaticSpeechRecognitionWord` - `End float64` The ending second when the word completes - `Start float64` The second this word begins in the recording - `Word string` - `type AIRunResponseImageClassification []AIRunResponseImageClassificationItem` - `Label string` The predicted category or class for the input image based on analysis - `Score float64` A confidence value, between 0 and 1, indicating how certain the model is about the predicted label - `type AIRunResponseObjectDetection []AIRunResponseObjectDetectionItem` An array of detected objects within the input image - `Box AIRunResponseObjectDetectionBox` Coordinates defining the bounding box around the detected object - `Xmax float64` The x-coordinate of the bottom-right corner of the bounding box - `Xmin float64` The x-coordinate of the top-left corner of the bounding box - `Ymax float64` The y-coordinate of the bottom-right corner of the bounding box - `Ymin float64` The y-coordinate of the top-left corner of the bounding box - `Label string` The class label or name of the detected object - `Score float64` Confidence score indicating the likelihood that the detection is correct - `type AIRunResponseObject struct{…}` - `Response string` The generated text response from the model - `ToolCalls []AIRunResponseObjectToolCall` 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 AIRunResponseObjectUsage` Usage statistics for the inference request - `CompletionTokens float64` Total number of tokens in output - `PromptTokens float64` Total number of tokens in input - `TotalTokens float64` Total number of input and output tokens - `UnionString` - `type AIRunResponseTranslation struct{…}` - `TranslatedText string` The translated text in the target language - `type AIRunResponseSummarization struct{…}` - `Summary string` The summarized version of the input text - `type AIRunResponseImageToText struct{…}` - `Description string` - `type AIRunResponseImageTextToText struct{…}` - `Description string` - `type AIRunResponseMultimodalEmbeddings struct{…}` - `Data [][]float64` - `Shape []float64` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/ai" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.AI.Run( context.TODO(), "model_name", ai.AIRunParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` #### Response ```json { "result": [ { "label": "label", "score": 0 } ] } ```