Run a Workers AI model·续1

type: optional string

Type of the content (text)

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content">Link to this property</a>

role: string

The role of the message sender (e.g., ‘user’, ‘assistant’, ‘system’, ‘tool’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20role">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages">Link to this property</a>

frequency_penalty: optional number

Decreases the likelihood of the model repeating the same lines verbatim.

maximum2

minimum-2

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20frequency_penalty">Link to this property</a>

<details>

<summary>

functions: optional array of object {code, name }

</summary>

code: string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20functions%20%3E%20(items)%20%3E%20(property)%20code">Link to this property</a>

name: string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20functions%20%3E%20(items)%20%3E%20(property)%20name">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20functions">Link to this property</a>

max_tokens: optional number

The maximum number of tokens to generate in the response.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20max_tokens">Link to this property</a>

presence_penalty: optional number

Increases the likelihood of the model introducing new topics.

maximum2

minimum-2

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20presence_penalty">Link to this property</a>

raw: optional boolean

If true, a chat template is not applied and you must adhere to the specific model’s expected formatting.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20raw">Link to this property</a>

repetition_penalty: optional number

Penalty for repeated tokens; higher values discourage repetition.

maximum2

minimum0

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20repetition_penalty">Link to this property</a>

<details>

<summary>

response_format: optional object {json_schema, type }

</summary>

json_schema: optional unknown

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20json_schema">Link to this property</a>

<details>

<summary>

type: optional "json_object"or "json_schema"

</summary>

One of the following:

"json_object"

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20type%20%3E%20(member)%200">Link to this property</a>

"json_schema"

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20type%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format">Link to this property</a>

seed: optional number

Random seed for reproducibility of the generation.

maximum9999999999

minimum1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20seed">Link to this property</a>

stream: optional boolean

If true, the response will be streamed back incrementally using SSE, Server Sent Events.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20stream">Link to this property</a>

temperature: optional number

Controls the randomness of the output; higher values produce more random results.

maximum5

minimum0

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20temperature">Link to this property</a>

<details>

<summary>

tools: optional array of object {description, name, parameters } or object {function, type }

A list of tools available for the assistant to use.

</summary>

One of the following:

<details>

<summary>

object {description, name, parameters }

</summary>

description: string

A brief description of what the tool does.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20description">Link to this property</a>

name: string

The name of the tool. More descriptive the better.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

parameters: object {properties, type, required }

Schema defining the parameters accepted by the tool.

</summary>

<details>

<summary>

properties: map[object {description, type } ]

Definitions of each parameter.

</summary>

description: string

A description of the expected parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20description">Link to this property</a>

type: string

The data type of the parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20properties">Link to this property</a>

type: string

The type of the parameters object (usually ‘object’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20type">Link to this property</a>

required: optional array of string

List of required parameter names.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20required">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

Function object {function, type }

</summary>

<details>

<summary>

function: object {description, name, parameters }

Details of the function tool.

</summary>

description: string

A brief description of what the function does.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20description">Link to this property</a>

name: string

The name of the function.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

parameters: object {properties, type, required }

Schema defining the parameters accepted by the function.

</summary>

<details>

<summary>

properties: map[object {description, type } ]

Definitions of each parameter.

</summary>

description: string

A description of the expected parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20description">Link to this property</a>

type: string

The data type of the parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20properties">Link to this property</a>

type: string

The type of the parameters object (usually ‘object’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20type">Link to this property</a>

required: optional array of string

List of required parameter names.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20required">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function">Link to this property</a>

type: string

Specifies the type of tool (e.g., ‘function’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools">Link to this property</a>

top_k: optional number

Limits the AI to choose from the top ‘k’ most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

maximum50

minimum1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20top_k">Link to this property</a>

top_p: optional number

Adjusts the creativity of the AI’s responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

maximum1

minimum0.001

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20top_p">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208">Link to this property</a>

<details>

<summary>

Translation object {target_lang, text, source_lang }

</summary>

target_lang: string

The language code to translate the text into (e.g., ‘es’ for Spanish)

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209%20%3E%20(property)%20target_lang">Link to this property</a>

text: string

The text to be translated

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209%20%3E%20(property)%20text">Link to this property</a>

source_lang: optional string

The language code of the source text (e.g., ‘en’ for English). Defaults to ‘en’ if not specified

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209%20%3E%20(property)%20source_lang">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209">Link to this property</a>

<details>

<summary>

Summarization object {input_text, max_length }

</summary>

input_text: string

The text that you want the model to summarize

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2010%20%3E%20(property)%20input_text">Link to this property</a>

max_length: optional number

The maximum length of the generated summary in tokens

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2010%20%3E%20(property)%20max_length">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2010">Link to this property</a>