Skip to content

Sending a prompt to a specific provider

INFERENCE DEFEND

This article is meant for Inference Defend users.

ROLES AND PERMISSIONS

To complete the task described in this section, make sure you have the required permissions.

When you have several available providers added to CalypsoAI, you may want to choose a specific provider and its models for your prompts. To send a prompt to an existing provider, you just need to provide the provider's name in your request.

In this scenario, we are going to send a prompt to a provider named openai.

To send a prompt to a specific provider:

  1. Add your token value to the following sample:

    python
    from 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 first 10 providers
    providers = cai.client.providers.get(limit=10).providers
    
    # Get the provider with name 'openai'
    openAIProvider = [provider for provider in providers if provider.name == 'openai'][0]
    
    # Send the prompt to the selected provider
    prompt = cai.prompts.send("What is your name?", provider=openAIProvider.id).model_dump_json()
    
    # Print the response
    print(prompt.model_dump_json(indent=2))
    • With cai.client, you can retrieve a paginated list of providers.
      The default limit of results per page is 10.
    • The providers list is inside the providers property of the providers object.

    PROVIDER NAME

    Make sure the provider name is the same as the value you specified when adding the provider to CalypsoAI.

    PAGINATION

    You can use the next and prev properties to access providers on specific pages.

  2. Run the script.

  3. Analyze the response.

    json
    {
        "externalMetadata": null,
        "fromTemplate": false,
        "id": "01964381-f1d1-70d9-8916-bc93395df181",
        "input": "What is your name?",
        "memory": null,
        "parentId": null,
        "preserve": false,
        "projectId": "01961aca-9df4-70eb-8514-bbb6f72d7032",
        "provider": "019639b7-0af8-70ec-8d41-06db530a12f2",
        "receivedAt": "2025-04-17T11:28:31.697871Z",
        "result": {
            "files": null,
            "outcome": "cleared",
            "providerResult": {
                "data": "I don't have a personal name. I'm an AI, and I exist only as a program designed to assist and communicate with users like you. I don't have a personal identity or consciousness, and I don't have the ability to form opinions or make decisions outside of my programming. I'm simply a tool designed to provide helpful and accurate information, answer questions, and engage in conversation!",
                "input": null,
                "receivedDate": "2025-04-17T11:28:32.292062Z",
                "sentDate": "2025-04-17T11:28:31.836322Z",
                "statusCode": 200
            },
            "response": "I don't have a personal name. I'm an AI, and I exist only as a program designed to assist and communicate with users like you. I don't have a personal identity or consciousness, and I don't have the ability to form opinions or make decisions outside of my programming. I'm simply a tool designed to provide helpful and accurate information, answer questions, and engage in conversation!",
            "scannerResults": [
                {
                    "completedDate": "2025-04-17T11:28:31.819486Z",
                    "customConfig": false,
                    "outcome": "passed",
                    "scanDirection": "request",
                    "scannerId": "019513f3-45f9-707b-aa90-8584d73229e8",
                    "startedDate": "2025-04-17T11:28:31.700602Z"
                }
            ]
        },
        "type": "prompt",
        "userId": "machine=01964360-af50-703f-b1f4-2a0b5bbf8b7c"
    }

Updated at: