Search K
Appearance
Appearance
ROLES AND PERMISSIONS
To complete the tasks described in this section, make sure you have the required permissions.
Before you can begin sending and scanning prompts, you must create a provider. A provider is a connection to an LLM or application, for example, an internally hosted model or an LLM created and hosted by a company.
To create a provider, we recommend using a system provider. System providers are easy-to-configure connections to hosted models.
SYSTEM PROVIDERS
We maintain the system providers and keep them up to date with any changes to the provider APIs.
When creating a new provider, you may find it useful to see all the system providers available to you. So, let's get a list of all available system providers.
To get a list of system providers:
Add your token value to the following sample:
from calypsoai import CalypsoAI
import calypsoai.datatypes as dt
# Define the URL and token for CalypsoAI
CALYPSOAI_URL = "https://www.us1.calypsoai.app"
CALYPSOAI_TOKEN = "ADD-YOUR-TOKEN-HERE"
# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
# Get the list of system providers
systemProviders = dt.GetSystemProvidersResponse(providers=[provider for provider in cai.providers.getSystem().values()])
# Print the response
print(systemProviders.model_dump_json(indent=2))Run the script.
Analyze the response.
The following response sample is a simplified version of a successful request, focusing only on the main details relevant to this specific request.
{
"providers": [
{
"id": "018bd88e-06bb-7021-86ab-c9a0b5efacbd",
"inputs": {
"model": "gpt-4o-mini",
"parameters": {
"frequency_penalty": 0,
"n": 1,
"presence_penalty": 0,
"temperature": 1,
"top_p": 1
}
},
"name": "openai-chat",
"secrets": {},
"template": {
"outputs": {
"content": "{{ content }}",
"statusCode": "{{ statusCode }}"
}
},
"type": "openai"
},
...
]
}The response includes the following key parameters:
providers > inputs > model: The model used by the system provider.providers > inputs > parameters: The parameters accepted by the model.providers > name: Name of the system provider, set by CalypsoAI.providers > secrets: The provider's API secret.providers > type: The provider type.{
"providers": [
{
"availability": {
"global_": false,
"projectIds": []
},
"hasLogo": false,
"id": "018bd88e-06bb-7021-86ab-c9a0b5efacbd",
"inputs": {
"model": "gpt-4o-mini",
"parameters": {
"frequency_penalty": 0,
"n": 1,
"presence_penalty": 0,
"temperature": 1,
"top_p": 1
}
},
"name": "openai-chat",
"orgId": null,
"projectId": null,
"redTeam": false,
"secrets": {},
"systemProviderId": null,
"tag": null,
"template": {
"outputs": {
"content": "{{ content }}",
"statusCode": "{{ statusCode }}"
},
"parsed": false,
"stages": [
{
"attempts": 3,
"backoff": "{{ 2 * attempt }}",
"block": {
"awsAuth": null,
"body": null,
"headers": {
"Accept": "application/json",
"Authorization": "Bearer {{ apiKey }}"
},
"json_": "{{ {...parameters, model, messages: [{role: 'system', content: 'You are
a helpful assistant.'}, ...Func.reduce((messages, memoryElem) => [...messages, {role: 'user',
content: memoryElem[0]}, {role: 'system', content: memoryElem[1]}], [], memory), {role:
'user', content: prompt}]} }}",
"method": "POST",
"outputs": {
"content": "{{ responseStatus == 200 ? responseJson.choices[0].message.content
: responseBody }}",
"statusCode": "{{ responseStatus }}"
},
"parsed": false,
"queryParams": {},
"timeout": 300,
"type": "request",
"url": "https://api.openai.com/v1/chat/completions"
},
"parsed": false,
"type": "retry",
"when": "{{ Array.contains([429, 500, 502, 503, 504], statusCode) }}"
}
],
"type": "workflow"
},
"type": "openai"
},
...
]
}Now, let's create a provider.
In this scenario, we are going to create a provider using the openai-chat system provider.
PREREQUISITES
Create an OpenAI API key. For details, see the OpenAI documentation.
To create a provider:
Edit the following sample.
from calypsoai import CalypsoAI
import calypsoai.datatypes as dt
# Define the URL and token for CalypsoAI
CALYPSOAI_URL = "https://www.us1.calypsoai.app"
CALYPSOAI_TOKEN = "ADD-YOUR-TOKEN-HERE"
# Define the key for OpenAI
OPENAI_KEY = "ADD-YOUR-OPENAI-KEY-HERE"
# Initialize the CalypsoAI client
cai = CalypsoAI(url=CALYPSOAI_URL, token=CALYPSOAI_TOKEN)
# Create the openai-chat provider
provider = cai.providers.create(
name="gpt-4",
systemProvider="openai-chat",
secrets={
"apiKey": {
"name": "ADD-YOUR-OPENAI-API-KEY-NAME-HERE",
"value": OPENAI_KEY
}
},
)
# Print the response
print(provider.model_dump_json(indent=2))cai.providers.create, do the following: name, provide a name for the provider.gpt-4.systemProvider, provide the name of the system provider you want to use.openai-chat.secrets > apiKey > name, provide the name of your OpenAI API key.Run the script.
Analyze the response.
The following response sample is a simplified version of a successful request, focusing only on the main details relevant to this specific request.
{
"id": "019667fa-d354-70bd-b32a-de720afdac5b",
"inputs": {
"model": "gpt-4o-mini",
"parameters": {
"frequency_penalty": 0,
"n": 1,
"presence_penalty": 0,
"temperature": 1,
"top_p": 1
}
},
"name": "gpt-4",
"secrets": {
"apiKey": "019667fa-d355-701f-8c7f-0b833fb158ce"
},
"systemProviderId": "018bd88e-06bb-7021-86ab-c9a0b5efacbd",
"template": {
"outputs": {
"content": "{{ content }}",
"statusCode": "{{ statusCode }}"
}
},
"type": "openai"
}The response includes the following key parameters:
inputs: The inputs configured by the user.name: The name of the provider.secrets > apiKey: The user's API key value for the provider.systemProviderId: The ID of the chosen system provider.type: The provider type.{
"availability": {
"global_": true,
"projectIds": []
},
"hasLogo": false,
"id": "0198ada0-136b-701f-9b90-988aa7d44ca2",
"inputs": {
"model": "gpt-4o-mini",
"parameters": {
"frequency_penalty": 0,
"n": 1,
"presence_penalty": 0,
"temperature": 1,
"top_p": 1
}
},
"maxRequestsPerSecond": null,
"name": "gpt-4",
"projectId": null,
"redTeam": false,
"secrets": {
"apiKey": "0198ada0-136b-7055-a365-2f8c749e3d5b"
},
"siem": false,
"systemProviderId": "018bd88e-06bb-7021-86ab-c9a0b5efacbd",
"tag": null,
"template": {
"outputs": {
"content": "{{ content }}",
"statusCode": "{{ statusCode }}"
},
"parsed": false,
"stages": [
{
"attempts": 3,
"backoff": "{{ 2 * attempt }}",
"block": {
"awsAuth": null,
"body": null,
"headers": {
"Accept": "application/json",
"Authorization": "Bearer {{ apiKey }}"
},
"json_": "{{ {...parameters, model, messages: Type.type(prompt) == 'array' ? prompt : [{role: 'system', content: 'You are a helpful assistant.'}, ...Func.reduce((messages, memoryElem) => [...messages, {role: 'user', content: memoryElem[0]}, {role: 'system', content: memoryElem[1]}], [], memory), {role: 'user', content: prompt}] } }}",
"method": "POST",
"outputs": {
"content": "{{ responseStatus == 200 ? responseJson.choices[0].message.content : responseBody }}",
"statusCode": "{{ responseStatus }}"
},
"parsed": false,
"queryParams": {},
"timeout": 300,
"type": "request",
"url": "https://api.openai.com/v1/chat/completions"
},
"parsed": false,
"type": "retry",
"when": "{{ Array.contains([429, 500, 502, 503, 504], statusCode) }}"
}
],
"type": "workflow"
},
"type": "openai"
}