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.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Execute AI model
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)
}
{
"result": [
{
"label": "label",
"score": 0
}
]
}Returns Examples
{
"result": [
{
"label": "label",
"score": 0
}
]
}