Search K
Appearance
Appearance
CONTENT MIGRATION
Documentation for F5 products will soon be moving to docs.f5.com — your new home for all F5 docs.
Use these examples to build a custom connection in F5 AI Security Platform. The example responses are fictional. Change the URLs and outputs expressions to match your endpoint.
Make sure you have:
us1.calypsoai.app or eu1.calypsoai.app.Examples that use apiKey set the Authorization header to the secret value. Enter the complete header value your endpoint requires as the secret. Select Custom as the authentication type to retain a header you write yourself.
For setup steps, see Connect with a custom connection. On the Custom model connection page, select an example from this page and adapt it to your endpoint. The example URLs and responses are fictional. For block types, fields, and expressions, see Custom connection YAML reference.
For each example:
{} in YAML template with the example request or workflow.The parameter lists show names and example values, not YAML to paste into a box. Replace example values with values from your provider. YAML quotes mark string values in the lists. Don't include those quotes in Value. In an apiKey secret, enter the complete Authorization header value your endpoint requires.
This example sends a model name and prompt, then reads output from the response. Use it on the Custom model connection page you opened in Open a custom connection. The URL and model name are examples. Replace them with values from your provider. Adjust the request and response expressions to match your endpoint.
Select the YAML parameters tab.
In Name, enter url. In Value, enter your endpoint URL.
Select Add parameter.
In Name, enter model. In Value, enter your model name.
For example, use https://llm.example.com/v1/chat for url and example-model-1 for model.
In YAML template, replace {} with the following request:
type: request
method: POST
url: '{{ url }}'
timeout: 60
headers:
Content-Type: application/json
Authorization: '{{ apiKey }}'
json: '{{ {model, input: prompt} }}'
outputs:
statusCode: '{{ response.statusCode }}'
content: '{{ response.statusCode == 200 ? response.json()?.output : null }}'
error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'If your endpoint accepts only an input field, omit the model parameter and replace the json line with:
json: '{{ {input: prompt} }}'Select the Connection settings tab.
In Authentication type, select Custom.
In Key, enter apiKey.
In Value, enter the complete Authorization header value.
Select Test and connect.
For the required outputs, see Custom connection YAML reference.
This example wraps the JSON request in a retry block. It runs up to three times and waits 2 seconds after the first attempt and 4 seconds after the second. On the Custom model connection page, add the url and model parameters under YAML parameters. Use your endpoint URL and model name, as in Call a JSON endpoint. In YAML template, replace {} or the existing request with this block:
type: retry
attempts: 3
backoff: '{{ 2 * attempt }}'
when: '{{ Array.contains([429, 500, 502, 503, 504], statusCode) }}'
block:
type: request
method: POST
url: '{{ url }}'
timeout: 60
headers:
Content-Type: application/json
Authorization: '{{ apiKey }}'
json: '{{ {model, input: prompt} }}'
outputs:
statusCode: '{{ response.statusCode }}'
content: '{{ response.statusCode == 200 ? response.json()?.output : null }}'
error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'For an endpoint that accepts only input, use the alternative json line from Call a JSON endpoint. Under Connection settings, select Custom and add the apiKey secret. Enter the complete Authorization header value in Value, then select Test and connect.
This example turns each pair in memory into a user message and an assistant message. The example endpoint returns {"reply": {"text": "..."}}.
On the Custom model connection page, select the YAML parameters tab. Add these parameters using Name and Value:
url: https://llm.example.com/v1/messages
systemPrompt: You are a helpful assistant.In YAML template, replace {} or the existing request with this block:
type: request
method: POST
url: '{{ url }}'
timeout: 60
headers:
Content-Type: application/json
Authorization: '{{ apiKey }}'
json: >-
{{ {
messages: [
{role: 'system', content: systemPrompt},
...Array.flatMap(turn => [{role: 'user', content: turn[0]}, {role: 'assistant', content: turn[1]}], memory),
{role: 'user', content: prompt}
]
} }}
outputs:
statusCode: '{{ response.statusCode }}'
content: '{{ response.json()?.reply?.text }}'
error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'Under Connection settings, select Custom and add the apiKey secret. Enter the complete Authorization header value in Value, then select Test and connect.
Use the YAML block scalar marker >- to split an expression across lines. If your endpoint takes one string instead of a list, use String.formatChat(prompt, memory). The function returns the conversation as lines that start with user: and assistant:.
This workflow creates a session, then sends it a prompt. The workflow outputs pass the required values to the top level.
On the Custom model connection page, select the YAML parameters tab. Add this parameter using Name and Value:
baseUrl: https://llm.example.comIn YAML template, replace {} or the existing request with this block:
type: workflow
stages:
- type: request
method: POST
url: '{{ baseUrl }}/v1/sessions'
headers:
Authorization: '{{ apiKey }}'
json: '{{ {} }}'
outputs:
sessionId: '{{ response.json()?.id }}'
- type: request
method: POST
url: '{{ baseUrl }}/v1/sessions/{{ sessionId }}/messages'
headers:
Authorization: '{{ apiKey }}'
json: '{{ {text: prompt} }}'
outputs:
statusCode: '{{ response.statusCode }}'
content: '{{ response.json()?.answer }}'
error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'
outputs:
statusCode: '{{ statusCode }}'
content: '{{ content }}'
error: '{{ error }}'Under Connection settings, select Custom and add the apiKey secret. Enter the complete Authorization header value in Value, then select Test and connect.
This example reads a server-sent events stream. Each event contains JSON with a delta field. The content output joins those values. Events that aren't JSON, such as [DONE], add nothing.
On the Custom model connection page, select the YAML parameters tab. Add this parameter using Name and Value:
url: https://llm.example.com/v1/streamIn YAML template, replace {} or the existing request with this block:
type: request
method: POST
url: '{{ url }}'
timeout: 300
headers:
Accept: text/event-stream
Authorization: '{{ apiKey }}'
json: '{{ {input: prompt, stream: true} }}'
outputs:
statusCode: '{{ response.statusCode }}'
content: >-
{{ response.statusCode == 200
? Array.reduce((text, event) => text + (event.json()?.delta ?? ''), '', response.events())
: null }}
error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'Under Connection settings, select Custom and add the apiKey secret. Enter the complete Authorization header value in Value, then select Test and connect.
The platform reads the whole stream before it returns the reply.
This example sends the prompt in a GET query string. The platform URL-encodes each value in queryParams.
On the Custom model connection page, select the YAML parameters tab. Add these parameters using Name and Value:
url: https://llm.example.com/v1/search
apiVersion: '2024-10-01'In YAML template, replace {} or the existing request with this block:
type: request
method: GET
url: '{{ url }}'
headers:
Authorization: '{{ apiKey }}'
queryParams:
q: '{{ prompt }}'
api-version: '{{ apiVersion }}'
outputs:
statusCode: '{{ response.statusCode }}'
content: '{{ response.json()?.result }}'
error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'Under Connection settings, select Custom and add the apiKey secret. Enter the complete Authorization header value in Value, then select Test and connect.
Use body for a form-encoded request and set Content-Type to application/x-www-form-urlencoded. The platform doesn't URL-encode values in body. If a value can contain reserved characters such as & or =, encode it before you store it.
For a standard OAuth 2.0 client credentials flow, select OAuth 2.0 under Authentication type. The platform then caches the token. Use a workflow for token requests only if your endpoint needs a request that OAuth 2.0 doesn't send.
This example requests a token for every prompt, then passes the token as the complete Authorization header value. Use it only if the token response contains the complete header value that your model endpoint requires.
On the Custom model connection page, select the YAML parameters tab. Add these parameters using Name and Value:
url: https://llm.example.com/v1/chat
tokenUrl: https://auth.example.com/oauth/tokenIn YAML template, replace {} or the existing request with this block:
type: workflow
stages:
- type: request
method: POST
url: '{{ tokenUrl }}'
headers:
Content-Type: application/x-www-form-urlencoded
body: 'grant_type=client_credentials&client_id={{ clientId }}&client_secret={{ clientSecret }}'
outputs:
token: '{{ response.json()?.access_token }}'
- type: request
method: POST
url: '{{ url }}'
headers:
Authorization: '{{ token }}'
json: '{{ {input: prompt} }}'
outputs:
statusCode: '{{ response.statusCode }}'
content: '{{ response.json()?.output }}'
error: '{{ response.statusCode == 200 ? null : String.decode(response.body) }}'
outputs:
statusCode: '{{ statusCode }}'
content: '{{ content }}'
error: '{{ error }}'Under Connection settings, select Custom. In Key, enter clientId. In Value, enter your client ID. Select Add new secret. In Key, enter clientSecret. In Value, enter your client secret. Select Test and connect.
On the Custom model connection page, select the Connection settings tab. In Example configuration, select an item to see a complete template. The list includes built-in provider templates.
| Example configuration | Endpoint |
|---|---|
openai-compatible-chat | OpenAI Chat Completions format |
anthropic | Anthropic Messages API, as a workflow block |
bedrock-converse | Amazon Bedrock Converse API, with an awsAuth block |
azure-openai-chat | Azure OpenAI deployments |
google-generate-content | Google Gemini generateContent API |
For common errors and fixes, see Troubleshooting a connection.