Skip to content

Custom connection YAML reference ​

Overview ​

Use this reference to set up a custom model connection in F5 AI Security Platform. The YAML in YAML template defines the HTTP request and how to read the response. This reference also covers parameters and credentials used by the template. For instructions and examples, see Connect to a model provider and Custom connection use cases.

Configuration parts ​

PartFormatContentsExample
YAML parametersName and value pairsNonsecret valuesurl, model, parameters
Connection settingsCredential fieldsEncrypted credentialsapiKey
YAML templateYAML blockThe request and its outputsA request block

Refer to an input or secret by name inside {{ }}, for example '{{ url }}'. Quote expressions in YAML values, unless you use a block scalar for a multiline expression. If an expression contains single quotes, use double quotes around the value.

Block types ​

The top-level configuration contains one block. You can nest blocks: retry wraps one block, and workflow runs multiple blocks. Select the type with the type field.

TypePurpose
requestSend one HTTP request and read the response.
retryRun a block again when a condition is true, such as a 429 status code.
workflowRun blocks in order and pass outputs to later blocks.

Request block ​

NameTypeRequiredDefaultDescription
typestringYesNoneSet to request.
methodstringYesNoneGET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS.
urlstringYesNoneFull endpoint URL. Only http and https URLs are allowed.
headersmapNo{}HTTP headers to send.
queryParamsmapNo{}Query parameters. The platform encodes each value and adds it to the URL.
jsonexpressionNoNoneJSON request body. If set, the platform ignores body.
bodystringNoNoneRaw request body. Set the Content-Type header yourself.
timeoutintegerNo20Time in seconds to wait for the whole response.
awsAuthmapNoNoneAWS Signature Version 4 fields. See AWS signing fields.
ociAuthmapNoNoneOracle Cloud Infrastructure signing fields. See OCI signing fields.
outputsmapNo{}Names and expressions to keep after the request. Only these names are available to later blocks.

In request outputs, use response to read the HTTP response.

ExpressionResult
response.statusCodeHTTP status code as a number
response.headersResponse headers
response.bodyRaw response body as bytes. Use String.decode(response.body) for text.
response.json()Parsed JSON response body, or null if the body isn't valid JSON
response.events()A list of server-sent events. Each event has data, event, id, and json().

Retry block ​

NameTypeRequiredDefaultDescription
typestringYesNoneSet to retry.
attemptsintegerYesNoneMaximum number of runs, including the first run.
blockblockYesNoneBlock to run.
whenexpressionNoNoneRetry while this expression is true. It can use outputs from the block, such as statusCode.
backoffnumber or expressionNo1Seconds to wait before the next attempt. attempt is the number of the attempt that just ran, starting at 1.

A retry block also retries network errors, such as a refused connection. It doesn't retry a blocked or invalid URL, or a certificate error. After the last attempt, its outputs remain available.

Workflow block ​

NameTypeRequiredDefaultDescription
typestringYesNoneSet to workflow.
stageslist of blocksYesNoneBlocks to run in order. Each stage's outputs are available to later stages.
outputsmapNo{}Names and expressions to keep after the workflow ends.

AWS signing fields ​

The awsAuth map signs a request with AWS Signature Version 4. To add the map in the UI, select AWS Sig V4 under Authentication type.

NameTypeRequiredDefaultDescription
servicestringYesNoneAWS service name, such as bedrock.
regionstringYesNoneAWS Region, such as us-east-1.
accessKeystringNoNoneAWS access key ID.
secretKeystringNoNoneAWS secret access key.
tokenstringNoNoneAWS session token for temporary credentials.

OCI signing fields ​

The ociAuth map signs a request for Oracle Cloud Infrastructure. The Authentication type list includes OCI.

NameTypeRequiredDefaultDescription
keyIdstringYesNoneOCI key ID, in the format <TENANCY_OCID>/<USER_OCID>/<KEY_FINGERPRINT>.
privateKeyPemstringYesNonePEM-encoded private key.
passphrasestringNoNonePassphrase for an encrypted private key.

Required outputs ​

The top-level block must return these outputs. The platform uses them to test the connection and read replies.

NameTypeDescription
statusCodenumberHTTP status code of the model call. The connection test passes only when the value is 200.
contentstringModel reply text.
errorstring or nullError message, or null when the call succeeds.

If statusCode is missing, the test reports "No statusCode output from provider". If the value isn't a valid HTTP status code, the test reports "Invalid status code returned from provider". In a workflow, include the required names in the workflow's outputs. See Run two requests in order.

Variables ​

Names are case-sensitive. If a name doesn't exist, the request reports Referenced undefined variable.

NameSourceDescription
promptF5 AI Security PlatformUser prompt. Usually a string. OpenAI-compatible proxy requests can use a list of messages. Use Type.type(prompt) == 'array' to check.
memoryF5 AI Security PlatformEarlier turns as [userMessage, assistantReply] pairs. Empty for the first turn and the connection test.
Any parameter nameYAML parametersEach parameter name.
Any secret nameConnection settingsEach secret key, including secrets added by an authentication type.
accessTokenF5 AI Security PlatformAccess token from OAuth 2.0 or JWT authentication.
attemptretry blockNumber of the attempt that just ran. Available only in backoff.
responserequest blockHTTP response. Available only in request outputs.

Expressions ​

Expressions are the text inside {{ }}. The syntax is similar to JavaScript. When a YAML value is a single expression, it keeps the result type. The result can be an object, a number, or a list. When a value mixes text and expressions, the result is a string. For example, if maxTokens is a number, '{{ maxTokens }}' is a number. The mixed value 'limit: {{ maxTokens }}' is a string.

SyntaxExample
Strings, numbers, true, false, null'text', "text", 42, 0.7
Lists and objects[1, 2], {role: 'user', content: prompt}
Object shorthand{model} means {model: model}
Spread[...memoryMessages, last], {...parameters, model}
Property and index accessbody.choices[0], list[-1] for the last item
Optional accessresponse.json()?.choices?.[0] returns null instead of an error
Arithmetic+, -, *, /. Use + to join strings.
Comparison==, !=, <, <=, >, >=
Logic&&, ||, !
Null fallbackvalue ?? 'default'
ConditionstatusCode == 200 ? content : null
Function(total, item) => total + item, turn => turn[0]
Local namelet message = response.json()?.message in message?.content
Comment// text to the end of the line

The + operator doesn't convert types. To join a string and a number, convert the number first or use Array.concat.

Helper functions ​

Call a helper by its library name, for example String.decode(response.body).

LibraryFunctions
Arraylength(list), index(list, i), slice(list, start, end), reverse(list), sort(list, fn), enumerate(list), range(start, end), contains(list, item), find(list, item), concat(list, separator), map(fn, list), filter(fn, list), flatMap(fn, list), reduce(fn, initial, list)
Base64encode(value), decode(value)
Datenow(format), timestamp(date), current_second(), current_minute(), current_hour(), current_day(), current_month()
Jsonencode(value), decode(text), getPath(value, path), setPath(value, path, newValue), jwtEncode(payload, privateKey, algorithm)
Mathnumber(value), floor(value), ceil(value), min(list), max(list)
Objectget(object, key, default), keys(object), values(object), merge(list), omit(object, keys)
Regexmatch(pattern, text, options)
Stringencode(text), decode(bytes), split(text, separator, max), random(length), formatChat(prompt, memory, options)
Typetype(value) returns string, integer, number, boolean, array, object, null, or bytestring

In map, filter, flatMap, and reduce, the function comes first and the list comes last. The Func library is an older name for Array.map, Array.filter, and Array.reduce. Use Array in new configurations.

Authentication types ​

When you select API Key, AWS Sig V4, Basic, Bearer, JWT, or OAuth 2.0, the platform changes every request block in YAML template. It first removes these headers: Authorization, authorization, apiKey, api-key, api_key, and x-api-key. Then it adds the header or block for the selected type.

For these types, the platform saves your values as secrets with fixed names. You can't add a secret with one of these names.

Authentication typeChange to each request blockSecrets added
API KeyAdds Authorization: '{{ apiKey }}'apiKey
BearerAdds an Authorization header using bearerTokenbearerToken
BasicAdds a Basic Authorization header with the Base64-encoded username and passwordusername, password
AWS Sig V4Adds Content-Type: application/json and an awsAuth blockaccessKey, secretKey, region, service, and token if entered
OAuth 2.0Adds an Authorization header using accessTokenauthUrl, clientId, clientSecret, and scope and audience if entered
JWTAdds an Authorization header using accessTokentokenUrl, issuer, subject, audience, privateKeyPem, algorithm, and keyId and scope if entered
CustomNo changeNone. Add secrets under Connection settings.
OCITo be confirmedTo be confirmed

For Basic, the Authorization header uses this value:

text
Basic {{Base64.encode(username + ':' + password)}}

The rewrite also removes comments and can change YAML formatting.

For example, a request can contain an x-api-key header:

yaml
type: request
method: POST
url: '{{ url }}'
headers:
  Content-Type: application/json
  x-api-key: '{{ apiKey }}'
json: '{{ {input: prompt} }}'
outputs:
  statusCode: '{{ response.statusCode }}'
  content: '{{ response.json()?.output }}'
  error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'

If you select Bearer, the platform removes x-api-key and adds an Authorization header using bearerToken. The other fields remain in the request. In this example, <BEARER_AUTHORIZATION_EXPRESSION> represents the generated header value.

yaml
type: request
method: POST
url: '{{ url }}'
headers:
  Content-Type: application/json
  Authorization: '<BEARER_AUTHORIZATION_EXPRESSION>'
json: '{{ {input: prompt} }}'
outputs:
  statusCode: '{{ response.statusCode }}'
  content: '{{ response.json()?.output }}'
  error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'

OAuth 2.0 and JWT ​

With OAuth 2.0 or JWT, the platform gets an access token before it calls your model. The token is available as accessToken.

  • OAuth 2.0: The platform sends a client credentials request to Auth URL. If the response includes a refresh token, the platform uses it to get the next token.
  • JWT: The platform signs a client assertion with your private key. The assertion expires after 120 seconds. The platform exchanges it for an access token at Token URL.

The platform reuses the token until about 90% of its expires_in time passes. If the response has no expires_in, the platform reuses the token for 60 minutes. Token requests retry on status codes 429, 500, 502, 503, and 504.

References ​

Updated at: