bmel:get-json-field¶
Category: JSON · Returns: bmel:any
bmel:get-json-field(object: bmel:any, field: bmel:json-field)
Description¶
Returns the value of one top-level field of a JSON object. The field is written with the #{FIELD_NAME} notation — the attribute reference operator (see Resource and field references operators).
When the object comes from bmel:get-resource-by-id, the BMEL editor knows its resource type: typing #{ lists that resource type's imported columns, the field name is validated against them, and the result takes the column's type — so a numeric column such as input_cost_per_token can be used directly in arithmetic. Returns null when the object is null or has no such field.
Arguments¶
| Parameter | Type | Required | Description |
|---|---|---|---|
object | bmel:any | The JSON object to read from — typically the result of bmel:get-resource-by-id. | |
field | bmel:json-field | The field to return, as #{FIELD_NAME} (e.g. #{input_cost_per_token}). |
Example¶
Cost of an invocation: input and output tokens, each times the model's price per token.
{invokeAgent:Response Payload}.$.usage.prompt_tokens *
bmel:get-json-field(bmel:get-resource-by-id(#{aimodel}, {invokeAgent:Request Payload}.$.model),
#{input_cost_per_token})
+ {invokeAgent:Response Payload}.$.usage.completion_tokens *
bmel:get-json-field(bmel:get-resource-by-id(#{aimodel}, {invokeAgent:Request Payload}.$.model),
#{output_cost_per_token})
Template dependency changes¶
Resource-type and attribute references written with #{Name} participate in mapping dependency validation, including nested calls. Removing or redefining a referenced dependency can invalidate the enclosing expression and trigger IntelliSense revalidation during editing or a Published-version fork. See ASBO dependencies in BMEL.