Appearance
Creating a provider
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.
Get a list of system providers
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:
pythonfrom calypsoai import CalypsoAI # 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 = cai.client.providers.system.get() # Print the response print(systemProviders.model_dump_json(indent=2))
Run the script.
Analyze the response.
json{ "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" }, ... ] }
LIST OF SYSTEM PROVIDERS
Our sample JSON response is a shortened version and only shows details for the
openai-chat
system provider. The full version shows all system providers.
Create a provider
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.
pythonfrom 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))
- Add your token value.
- Add your OpenAI API key value.
You should get your OpenAI API key details from the provider's website. - In
name
, provide a name for the provider.
In this scenario, we will call the providergpt-4
. - In
systemProvider
, provide the name of the system provider you want to use.
In this scenario, the system provider isopenai-chat
. - In
apiKey
>name
, provide the name of your OpenAI API key.
You should get your OpenAI API key details from the provider's website.
Run the script.
Analyze the response.
json{ "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" }