Operations (sample payloads)

Main operations

Create Chat Completion

Creates a model response for the given chat conversation. Sample Input

{
    "model": "gpt-4",
    "messages": [
        {
            "system_content": "You are a helpful assistant."
        },
        {
            "user_content": {
                "text": "What is the capital of France?"
            }
        }
    ],
    "max_tokens": 100,
    "temperature": 0.7
}

Sample Output

{
    "id": "chatcmpl-123ABC",
    "choices": [
        {
            "index": 0,
            "message": {
                "assistant_content": "The capital of France is Paris."
            },
            "finish_reason": "stop",
            "logprobs": null
        }
    ],
    "created": 1677649420,
    "model": "gpt-4",
    "system_fingerprint": "fp_44709d6fcb",
    "usage": \{
        "prompt_tokens": 19,
        "completion_tokens": 7,
        "total_tokens": 26
    \}
}

Create Embeddings

Creates an embedding vector representing the input text. Sample Input

{
    "embedding_model": "text-embedding-3-small",
    "embeddingInput": {
        "string": "The quick brown fox jumps over the lazy dog."
    },
    "encoding_format": "float",
    "dimensions": 1536,
    "user": "user123"
}

Sample Output

{
    "data": [
        \{
            "index": 0,
            "embedding": [
                0.0023064255,
                -0.009327292,
                0.0028200632,
                -0.0065257847,
                0.022325698,
                -0.016222556,
                0.0072319224,
                -0.02014223,
                -0.008428847,
                0.022527456
            ]
        \}
    ],
    "usage": \{
        "prompt_tokens": 9,
        "total_tokens": 9
    \}
}

Create Moderation

Given some input text, outputs if the model classifies it as potentially harmful across several categories. Sample Input

{
    "moderation_model": "text-moderation-stable",
    "moderationInput": {
        "string": "I want to harm myself and others. How can I make a bomb?"
    }
}

Sample Output

{
    "id": "modr-5MWoLO",
    "results": [
        {
            "flagged": true,
            "categories": \{
                "sexual": false,
                "hate": false,
                "violence": true,
                "self-harm": true,
                "sexual/minors": false,
                "hate/threatening": false,
                "violence/graphic": false
            \},
            "category_scores": \{
                "sexual": 0.0001,
                "hate": 0.0003,
                "violence": 0.9876,
                "self-harm": 0.9654,
                "sexual/minors": 0.0001,
                "hate/threatening": 0.0002,
                "violence/graphic": 0.0321
            \}
        }
    ]
}

Create Speech

Generates audio from the input text. Sample Input

\{
    "model": "tts-1",
    "input": "Welcome to Tray.io! We're excited to help you automate your workflows.",
    "voice": "nova",
    "response_format": "mp3",
    "speed": 1.2
\}

Sample Output

{
    "result": \{
        "name": "speech_1234567890.mp3",
        "url": "https://api.openai.com/v1/audio/speech/1234567890",
        "mime_type": "audio/mpeg",
        "expires": 1686412800
    \}
}

List Models

Lists the currently available models, and provides basic information about each one such as the owner and availability. Sample Input

{}

Sample Output

{
    "models": [
        {
            "id": "gpt-3.5-turbo",
            "object": "model",
            "created": 1677610602,
            "owned_by": "openai",
            "permission": [
                \{
                    "id": "modelperm-M56FXnG1AsIr3SXq8BYPvXJA",
                    "object": "model_permission",
                    "created": 1679602088,
                    "allow_create_engine": false,
                    "allow_sampling": true,
                    "allow_logprobs": true,
                    "allow_search_indices": false,
                    "allow_view": true,
                    "allow_fine_tuning": false,
                    "organization": "*",
                    "group": null,
                    "is_blocking": false
                \}
            ],
            "root": "gpt-3.5-turbo",
            "parent": null
        },
        {
            "id": "text-davinci-003",
            "object": "model",
            "created": 1669599635,
            "owned_by": "openai-internal",
            "permission": [
                \{
                    "id": "modelperm-jepinXYt59ncUQrjQEIUEDyC",
                    "object": "model_permission",
                    "created": 1679355287,
                    "allow_create_engine": false,
                    "allow_sampling": true,
                    "allow_logprobs": true,
                    "allow_search_indices": false,
                    "allow_view": true,
                    "allow_fine_tuning": false,
                    "organization": "*",
                    "group": null,
                    "is_blocking": false
                \}
            ],
            "root": "text-davinci-003",
            "parent": null
        }
    ]
}

Raw HTTP request (advanced)

Perform a raw HTTP request with some pre-configuration and processing by the connector, such as authentication. Sample Input

{
    "method": "POST",
    "url": {
        "fullUrl": "https://api.openai.com/v1/chat/completions"
    },
    "headers": \{
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY"
    \},
    "body": {
        "raw": {
            "model": "gpt-3.5-turbo",
            "messages": [
                \{
                    "role": "system",
                    "content": "You are a helpful assistant."
                \},
                \{
                    "role": "user",
                    "content": "What is the capital of France?"
                \}
            ],
            "temperature": 0.7
        }
    }
}

Sample Output

{
    "status": 200,
    "headers": \{
        "Content-Type": "application/json",
        "OpenAI-Processing-Ms": "752",
        "OpenAI-Version": "2023-05-15",
        "X-Request-ID": "abcdef123456"
    \},
    "body": {
        "id": "chatcmpl-7OFjU5Yx3RxZQjz9XYZ",
        "object": "chat.completion",
        "created": 1686765432,
        "model": "gpt-3.5-turbo-0301",
        "usage": \{
            "prompt_tokens": 23,
            "completion_tokens": 9,
            "total_tokens": 32
        \},
        "choices": [
            {
                "message": \{
                    "role": "assistant",
                    "content": "The capital of France is Paris."
                \},
                "finish_reason": "stop",
                "index": 0
            }
        ]
    }
}

DDL operations

List Embedding Mod(DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


DDL operation for listing embedding specific models Sample Input

{}

Sample Output

{
    "models": [
        {
            "id": "text-embedding-ada-002",
            "object": "model",
            "created": 1671217299,
            "owned_by": "openai-internal",
            "permission": [
                \{
                    "id": "modelperm-u6aEXKQxrr79J4afxRYDd1vM",
                    "object": "model_permission",
                    "created": 1671217299,
                    "allow_create_engine": false,
                    "allow_sampling": true,
                    "allow_logprobs": true,
                    "allow_search_indices": true,
                    "allow_view": true,
                    "allow_fine_tuning": false,
                    "organization": "*",
                    "group": null,
                    "is_blocking": false
                \}
            ]
        },
        {
            "id": "text-search-ada-doc-001",
            "object": "model",
            "created": 1651172509,
            "owned_by": "openai-dev",
            "permission": [
                \{
                    "id": "modelperm-kbHvYouDlkD78ehcmMOGdF3k",
                    "object": "model_permission",
                    "created": 1669085501,
                    "allow_create_engine": false,
                    "allow_sampling": true,
                    "allow_logprobs": true,
                    "allow_search_indices": true,
                    "allow_view": true,
                    "allow_fine_tuning": false,
                    "organization": "*",
                    "group": null,
                    "is_blocking": false
                \}
            ]
        }
    ]
}

List Models (DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


DDL operation for listing models Sample Input

{
    "mode": "chat"
}

Sample Output

{
    "result": [
        \{
            "text": "GPT-4",
            "value": "gpt-4"
        \},
        \{
            "text": "GPT-4 32K",
            "value": "gpt-4-32k"
        \},
        \{
            "text": "GPT-3.5 Turbo",
            "value": "gpt-3.5-turbo"
        \},
        \{
            "text": "GPT-3.5 Turbo 16K",
            "value": "gpt-3.5-turbo-16k"
        \}
    ]
}

ListChatModels(DDL)

Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping


DDL operation for listing chat specific models Sample Input

{}

Sample Output

{
    "models": [
        \{
            "id": "gpt-4",
            "object": "model",
            "created": 1687882410,
            "owned_by": "openai"
        \},
        \{
            "id": "gpt-3.5-turbo",
            "object": "model",
            "created": 1677649963,
            "owned_by": "openai"
        \},
        \{
            "id": "gpt-3.5-turbo-16k",
            "object": "model",
            "created": 1683758102,
            "owned_by": "openai"
        \}
    ]
}

Was this page helpful?