Cloudflare.WorkersAI (Cloudflare v0.5.0)

Copy Markdown View Source

Workers AI

GET /accounts/{account_id}/ai/authors/search

Responses

200 Returns a list of authors

Data is at body["result"]

[
  {}
]
400 Bad Request
{
  "errors": [
    {
      "message": "*string*"
    }
  ],
  "result": {},
  "success": "*boolean*"
}

Get Model Schema

GET /accounts/{account_id}/ai/models/schema

Responses

200 Model Schema

Data is at body["result"]

{
  "input": {
    "additionalProperties": "*boolean*",
    "description": "*string*",
    "type": "*string*"
  },
  "output": {
    "additionalProperties": "*boolean*",
    "description": "*string*",
    "type": "*string*"
  }
}
400 Bad Request
{
  "errors": [
    {
      "message": "*string*"
    }
  ],
  "result": {},
  "success": "*boolean*"
}

GET /accounts/{account_id}/ai/models/search

Responses

200 Returns a list of models

Data is at body["result"]

[
  {}
]
404 Object not found
{
  "errors": [
    {}
  ],
  "success": "*boolean*"
}

Execute AI model

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.

Responses

200 Model response

Data is at body["result"]

{}
400 Bad Request
{
  "errors": [
    {
      "message": "*string*"
    }
  ],
  "result": {},
  "success": "*boolean*"
}

GET /accounts/{account_id}/ai/tasks/search

Responses

200 Returns a list of tasks

Data is at body["result"]

[
  {}
]
404 Object not found
{
  "errors": [
    {}
  ],
  "success": "*boolean*"
}

Convert Files into Markdown

POST /accounts/{account_id}/ai/tomarkdown

Responses

200 Model Schema

Data is at body["result"]

[
  {
    "data": "*string*",
    "format": "*string*",
    "mimeType": "*string*",
    "name": "*string*",
    "tokens": "*string*"
  }
]
400 Bad Request
{
  "errors": [
    {
      "message": "*string*"
    }
  ],
  "result": {},
  "success": "*boolean*"
}

Get all converted formats supported

GET /accounts/{account_id}/ai/tomarkdown/supported

Responses

200 Successful response

Data is at body["result"]

[
  {
    "extension": "*string*",
    "mimeType": "*string*"
  }
]
400 Bad Request
{
  "errors": [
    {
      "message": "*string*"
    }
  ],
  "result": {},
  "success": "*boolean*"
}

Summary

Functions

Gets the schema for a specific AI model.

Searches available AI models.

Executes an AI model with the given input.

Searches available AI tasks.

Functions

client(opts \\ [])

model_schema(opts \\ [])

Gets the schema for a specific AI model.

models(opts \\ [])

Searches available AI models.

path_for(id, opts \\ [])

@spec path_for(term(), [{:action, String.t()}]) :: String.t()

run(model_name, body, opts \\ [])

Executes an AI model with the given input.

tasks(opts \\ [])

Searches available AI tasks.