Skip to content

Chat Completion

The chat completion API provides an OpenAI-compatible interface for secure LLM interactions.

ChatResource

ChatResource(transport: ControlSyncTransport)

OpenAI-compatible chat completions — client.control.chat.

Methods:

  • create

    Send a chat completion request through Sequrity's secure orchestrator.

create

create(
    messages: list[Message | dict],
    model: str,
    *,
    temperature: float | None = None,
    top_p: float | None = None,
    tools: list[Tool | dict] | None = None,
    stream: Literal[True],
    seed: int | None = None,
    reasoning_effort: ReasoningEffort | None = None,
    response_format: ResponseFormat | None = None,
    provider: LlmServiceProvider | LlmServiceProviderStr | None | _NotGiven = NOT_GIVEN,
    llm_api_key: str | None | _NotGiven = NOT_GIVEN,
    features: FeaturesHeader | None | _NotGiven = NOT_GIVEN,
    security_policy: SecurityPolicyHeader | None | _NotGiven = NOT_GIVEN,
    fine_grained_config: FineGrainedConfigHeader | None | _NotGiven = NOT_GIVEN,
    endpoint_type: str | _NotGiven = NOT_GIVEN,
    session_id: str | None | _NotGiven = NOT_GIVEN,
    feature_overrides: dict[str, Any] | None = None,
    policy_overrides: dict[str, Any] | None = None,
    config_overrides: dict[str, Any] | None = None,
    custom_headers: dict[str, str] | None = None,
) -> SyncStream[ChatCompletionChunk]
create(
    messages: list[Message | dict],
    model: str,
    *,
    temperature: float | None = None,
    top_p: float | None = None,
    tools: list[Tool | dict] | None = None,
    stream: Literal[False] | None = None,
    seed: int | None = None,
    reasoning_effort: ReasoningEffort | None = None,
    response_format: ResponseFormat | None = None,
    provider: LlmServiceProvider | LlmServiceProviderStr | None | _NotGiven = NOT_GIVEN,
    llm_api_key: str | None | _NotGiven = NOT_GIVEN,
    features: FeaturesHeader | None | _NotGiven = NOT_GIVEN,
    security_policy: SecurityPolicyHeader | None | _NotGiven = NOT_GIVEN,
    fine_grained_config: FineGrainedConfigHeader | None | _NotGiven = NOT_GIVEN,
    endpoint_type: str | _NotGiven = NOT_GIVEN,
    session_id: str | None | _NotGiven = NOT_GIVEN,
    feature_overrides: dict[str, Any] | None = None,
    policy_overrides: dict[str, Any] | None = None,
    config_overrides: dict[str, Any] | None = None,
    custom_headers: dict[str, str] | None = None,
) -> ChatCompletionResponse
create(
    messages: list[Message | dict],
    model: str,
    *,
    temperature: float | None = None,
    top_p: float | None = None,
    tools: list[Tool | dict] | None = None,
    stream: bool | None = None,
    seed: int | None = None,
    reasoning_effort: ReasoningEffort | None = None,
    response_format: ResponseFormat | None = None,
    provider: LlmServiceProvider | LlmServiceProviderStr | None | _NotGiven = NOT_GIVEN,
    llm_api_key: str | None | _NotGiven = NOT_GIVEN,
    features: FeaturesHeader | None | _NotGiven = NOT_GIVEN,
    security_policy: SecurityPolicyHeader | None | _NotGiven = NOT_GIVEN,
    fine_grained_config: FineGrainedConfigHeader | None | _NotGiven = NOT_GIVEN,
    endpoint_type: str | _NotGiven = NOT_GIVEN,
    session_id: str | None | _NotGiven = NOT_GIVEN,
    feature_overrides: dict[str, Any] | None = None,
    policy_overrides: dict[str, Any] | None = None,
    config_overrides: dict[str, Any] | None = None,
    custom_headers: dict[str, str] | None = None,
) -> ChatCompletionResponse | SyncStream[ChatCompletionChunk]

Send a chat completion request through Sequrity's secure orchestrator.

Parameters:

  • messages

    (list[Message | dict]) –

    List of chat messages in the conversation.

  • model

    (str) –

    The LLM model identifier (e.g., "gpt-4o", "openai/gpt-5-mini").

  • temperature

    (float | None, default: None ) –

    Sampling temperature.

  • top_p

    (float | None, default: None ) –

    Nucleus sampling parameter.

  • tools

    (list[Tool | dict] | None, default: None ) –

    List of tools available to the model.

  • stream

    (bool | None, default: None ) –

    Whether to stream the response. When True, returns a :class:SyncStream of :class:ChatCompletionChunk objects.

  • seed

    (int | None, default: None ) –

    Random seed for reproducibility.

  • reasoning_effort

    (ReasoningEffort | None, default: None ) –

    Reasoning effort level for supported models.

  • response_format

    (ResponseFormat | None, default: None ) –

    Response format specification.

  • provider

    (LlmServiceProvider | LlmServiceProviderStr | None | _NotGiven, default: NOT_GIVEN ) –

    LLM service provider override.

  • llm_api_key

    (str | None | _NotGiven, default: NOT_GIVEN ) –

    LLM provider API key override.

  • features

    (FeaturesHeader | None | _NotGiven, default: NOT_GIVEN ) –

    Security features override.

  • security_policy

    (SecurityPolicyHeader | None | _NotGiven, default: NOT_GIVEN ) –

    Security policy override.

  • fine_grained_config

    (FineGrainedConfigHeader | None | _NotGiven, default: NOT_GIVEN ) –

    Fine-grained config override.

  • endpoint_type

    (str | _NotGiven, default: NOT_GIVEN ) –

    Endpoint type override.

  • session_id

    (str | None | _NotGiven, default: NOT_GIVEN ) –

    Explicit session ID override.

  • feature_overrides

    (dict[str, Any] | None, default: None ) –

    Dict to deep-merge into the serialized X-Features header JSON. Allows adding or overriding fields without loosening Pydantic validation on :class:FeaturesHeader.

  • policy_overrides

    (dict[str, Any] | None, default: None ) –

    Dict to deep-merge into the serialized X-Policy header JSON.

  • config_overrides

    (dict[str, Any] | None, default: None ) –

    Dict to deep-merge into the serialized X-Config header JSON.

Returns:

  • ChatCompletionResponse | SyncStream[ChatCompletionChunk]

    ChatCompletionResponse when stream is False/None,

  • ChatCompletionResponse | SyncStream[ChatCompletionChunk]

    or SyncStream[ChatCompletionChunk] when stream is True.


ChatCompletionRequest pydantic-model

OpenAI Chat Completion request.

This is a Pydantic model representation of the OpenAI chat completion request, containing only the specified subset of fields.

Show JSON schema:
{
  "$defs": {
    "AssistantMessage": {
      "description": "Assistant message.",
      "properties": {
        "role": {
          "const": "assistant",
          "description": "The role of the messages author, in this case 'assistant'.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "anyOf": [
                  {
                    "$ref": "#/$defs/ContentPartText"
                  },
                  {
                    "$ref": "#/$defs/ContentPartRefusal"
                  }
                ]
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The contents of the assistant message. Required unless tool_calls or function_call is specified.",
          "title": "Content"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
          "title": "Name"
        },
        "refusal": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The refusal message by the assistant.",
          "title": "Refusal"
        },
        "audio": {
          "anyOf": [
            {
              "$ref": "#/$defs/AssistantMessageAudio"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Data about a previous audio response from the model."
        },
        "tool_calls": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/ToolCall"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The tool calls generated by the model, such as function calls.",
          "title": "Tool Calls"
        },
        "function_call": {
          "anyOf": [
            {
              "$ref": "#/$defs/FunctionCallResult"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Deprecated and replaced by tool_calls. The name and arguments of a function that should be called."
        }
      },
      "required": [
        "role"
      ],
      "title": "AssistantMessage",
      "type": "object"
    },
    "AssistantMessageAudio": {
      "description": "Audio reference in assistant message.",
      "properties": {
        "id": {
          "description": "Unique identifier for a previous audio response from the model.",
          "title": "Id",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "title": "AssistantMessageAudio",
      "type": "object"
    },
    "ContentPartFile": {
      "description": "File content part.",
      "properties": {
        "type": {
          "const": "file",
          "description": "The type of the content part. Always 'file'.",
          "title": "Type",
          "type": "string"
        },
        "file": {
          "$ref": "#/$defs/FileData",
          "description": "The file data."
        }
      },
      "required": [
        "type",
        "file"
      ],
      "title": "ContentPartFile",
      "type": "object"
    },
    "ContentPartImage": {
      "description": "Image content part.",
      "properties": {
        "type": {
          "const": "image_url",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "image_url": {
          "$ref": "#/$defs/ImageUrl",
          "description": "The image URL details."
        }
      },
      "required": [
        "type",
        "image_url"
      ],
      "title": "ContentPartImage",
      "type": "object"
    },
    "ContentPartInputAudio": {
      "description": "Input audio content part.",
      "properties": {
        "type": {
          "const": "input_audio",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "input_audio": {
          "$ref": "#/$defs/InputAudioData",
          "description": "The input audio data."
        }
      },
      "required": [
        "type",
        "input_audio"
      ],
      "title": "ContentPartInputAudio",
      "type": "object"
    },
    "ContentPartRefusal": {
      "description": "Refusal content part.",
      "properties": {
        "type": {
          "const": "refusal",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "refusal": {
          "description": "The refusal message.",
          "title": "Refusal",
          "type": "string"
        }
      },
      "required": [
        "type",
        "refusal"
      ],
      "title": "ContentPartRefusal",
      "type": "object"
    },
    "ContentPartText": {
      "description": "Text content part.",
      "properties": {
        "type": {
          "const": "text",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "text": {
          "description": "The text content.",
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "type",
        "text"
      ],
      "title": "ContentPartText",
      "type": "object"
    },
    "DeveloperMessage": {
      "description": "Developer message.",
      "properties": {
        "role": {
          "const": "developer",
          "description": "The role of the messages author, in this case 'developer'.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "$ref": "#/$defs/ContentPartText"
              },
              "type": "array"
            }
          ],
          "description": "The contents of the developer message.",
          "title": "Content"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
          "title": "Name"
        }
      },
      "required": [
        "role",
        "content"
      ],
      "title": "DeveloperMessage",
      "type": "object"
    },
    "FileData": {
      "description": "File data.",
      "properties": {
        "file_data": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The base64 encoded file data, used when passing the file to the model as a string.",
          "title": "File Data"
        },
        "file_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The ID of an uploaded file to use as input.",
          "title": "File Id"
        },
        "filename": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The name of the file, used when passing the file to the model as a string.",
          "title": "Filename"
        }
      },
      "title": "FileData",
      "type": "object"
    },
    "FunctionCallResult": {
      "description": "Function call result in assistant message.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "FunctionCallResult",
      "type": "object"
    },
    "FunctionDefinition": {
      "description": "Function definition for tools.",
      "properties": {
        "name": {
          "description": "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.",
          "title": "Name",
          "type": "string"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A description of what the function does, used by the model to choose when and how to call the function.",
          "title": "Description"
        },
        "parameters": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The parameters the functions accepts, described as a JSON Schema object.",
          "title": "Parameters"
        },
        "strict": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Whether to enable strict schema adherence when generating the function call.",
          "title": "Strict"
        }
      },
      "required": [
        "name"
      ],
      "title": "FunctionDefinition",
      "type": "object"
    },
    "FunctionMessage": {
      "description": "Function message (deprecated).",
      "properties": {
        "role": {
          "const": "function",
          "description": "The role of the messages author, in this case 'function'.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The contents of the function message.",
          "title": "Content"
        },
        "name": {
          "description": "The name of the function.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "role",
        "content",
        "name"
      ],
      "title": "FunctionMessage",
      "type": "object"
    },
    "FunctionTool": {
      "description": "Function tool.",
      "properties": {
        "type": {
          "const": "function",
          "description": "The type of the tool. Currently, only 'function' is supported.",
          "title": "Type",
          "type": "string"
        },
        "function": {
          "$ref": "#/$defs/FunctionDefinition",
          "description": "The function definition."
        }
      },
      "required": [
        "type",
        "function"
      ],
      "title": "FunctionTool",
      "type": "object"
    },
    "ImageUrl": {
      "description": "Image URL details.",
      "properties": {
        "url": {
          "description": "Either a URL of the image or the base64 encoded image data.",
          "title": "Url",
          "type": "string"
        },
        "detail": {
          "anyOf": [
            {
              "enum": [
                "auto",
                "low",
                "high"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Specifies the detail level of the image. 'low', 'high', or 'auto' for automatic selection.",
          "title": "Detail"
        }
      },
      "required": [
        "url"
      ],
      "title": "ImageUrl",
      "type": "object"
    },
    "InputAudioData": {
      "description": "Input audio data.",
      "properties": {
        "data": {
          "description": "Base64 encoded audio data.",
          "title": "Data",
          "type": "string"
        },
        "format": {
          "description": "The format of the audio data.",
          "enum": [
            "wav",
            "mp3"
          ],
          "title": "Format",
          "type": "string"
        }
      },
      "required": [
        "data",
        "format"
      ],
      "title": "InputAudioData",
      "type": "object"
    },
    "JsonSchema": {
      "additionalProperties": false,
      "description": "JSON schema definition.",
      "properties": {
        "name": {
          "description": "The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.",
          "title": "Name",
          "type": "string"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A description of what the response format is for, used by the model to determine how to respond in the format.",
          "title": "Description"
        },
        "schema": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The schema for the response format, described as a JSON Schema object.",
          "title": "Schema"
        },
        "strict": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Whether to enable strict schema adherence when generating the output.",
          "title": "Strict"
        }
      },
      "required": [
        "name"
      ],
      "title": "JsonSchema",
      "type": "object"
    },
    "ResponseFormatJsonObject": {
      "description": "JSON object response format.",
      "properties": {
        "type": {
          "const": "json_object",
          "description": "The type of response format being defined. Always 'json_object'.",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "title": "ResponseFormatJsonObject",
      "type": "object"
    },
    "ResponseFormatJsonSchema": {
      "description": "JSON schema response format.",
      "properties": {
        "type": {
          "const": "json_schema",
          "description": "The type of response format being defined. Always 'json_schema'.",
          "title": "Type",
          "type": "string"
        },
        "json_schema": {
          "$ref": "#/$defs/JsonSchema",
          "description": "Structured Outputs configuration options, including a JSON Schema."
        }
      },
      "required": [
        "type",
        "json_schema"
      ],
      "title": "ResponseFormatJsonSchema",
      "type": "object"
    },
    "ResponseFormatText": {
      "description": "Text response format.",
      "properties": {
        "type": {
          "const": "text",
          "description": "The type of response format being defined. Always 'text'.",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "title": "ResponseFormatText",
      "type": "object"
    },
    "SystemMessage": {
      "description": "System message.",
      "properties": {
        "role": {
          "const": "system",
          "description": "The role of the messages author, in this case 'system'.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "$ref": "#/$defs/ContentPartText"
              },
              "type": "array"
            }
          ],
          "description": "The contents of the system message.",
          "title": "Content"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
          "title": "Name"
        }
      },
      "required": [
        "role",
        "content"
      ],
      "title": "SystemMessage",
      "type": "object"
    },
    "ToolCall": {
      "description": "Tool call in assistant message.",
      "properties": {
        "id": {
          "description": "The ID of the tool call.",
          "title": "Id",
          "type": "string"
        },
        "type": {
          "const": "function",
          "description": "The type of the tool. Currently, only 'function' is supported.",
          "title": "Type",
          "type": "string"
        },
        "function": {
          "$ref": "#/$defs/ToolCallFunction",
          "description": "The function that the model called."
        }
      },
      "required": [
        "id",
        "type",
        "function"
      ],
      "title": "ToolCall",
      "type": "object"
    },
    "ToolCallFunction": {
      "description": "Function details in tool call.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "ToolCallFunction",
      "type": "object"
    },
    "ToolMessage": {
      "description": "Tool message.",
      "properties": {
        "role": {
          "const": "tool",
          "description": "The role of the messages author, in this case 'tool'.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "$ref": "#/$defs/ContentPartText"
              },
              "type": "array"
            }
          ],
          "description": "The contents of the tool message.",
          "title": "Content"
        },
        "tool_call_id": {
          "description": "Tool call that this message is responding to.",
          "title": "Tool Call Id",
          "type": "string"
        }
      },
      "required": [
        "role",
        "content",
        "tool_call_id"
      ],
      "title": "ToolMessage",
      "type": "object"
    },
    "UserMessage": {
      "description": "User message.",
      "properties": {
        "role": {
          "const": "user",
          "description": "The role of the messages author, in this case 'user'.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "anyOf": [
                  {
                    "$ref": "#/$defs/ContentPartText"
                  },
                  {
                    "$ref": "#/$defs/ContentPartImage"
                  },
                  {
                    "$ref": "#/$defs/ContentPartInputAudio"
                  },
                  {
                    "$ref": "#/$defs/ContentPartFile"
                  }
                ]
              },
              "type": "array"
            }
          ],
          "description": "The contents of the user message.",
          "title": "Content"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
          "title": "Name"
        }
      },
      "required": [
        "role",
        "content"
      ],
      "title": "UserMessage",
      "type": "object"
    }
  },
  "description": "OpenAI Chat Completion request.\n\nThis is a Pydantic model representation of the OpenAI chat completion request,\ncontaining only the specified subset of fields.",
  "properties": {
    "messages": {
      "description": "A list of messages comprising the conversation so far.",
      "items": {
        "discriminator": {
          "mapping": {
            "assistant": "#/$defs/AssistantMessage",
            "developer": "#/$defs/DeveloperMessage",
            "function": "#/$defs/FunctionMessage",
            "system": "#/$defs/SystemMessage",
            "tool": "#/$defs/ToolMessage",
            "user": "#/$defs/UserMessage"
          },
          "propertyName": "role"
        },
        "oneOf": [
          {
            "$ref": "#/$defs/DeveloperMessage"
          },
          {
            "$ref": "#/$defs/SystemMessage"
          },
          {
            "$ref": "#/$defs/UserMessage"
          },
          {
            "$ref": "#/$defs/AssistantMessage"
          },
          {
            "$ref": "#/$defs/ToolMessage"
          },
          {
            "$ref": "#/$defs/FunctionMessage"
          }
        ]
      },
      "title": "Messages",
      "type": "array"
    },
    "model": {
      "description": "Model ID used to generate the response, like 'gpt-4o' or 'o3'.",
      "title": "Model",
      "type": "string"
    },
    "reasoning_effort": {
      "anyOf": [
        {
          "enum": [
            "none",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Constrains effort on reasoning for reasoning models. Supported values are 'none', 'minimal', 'low', 'medium', 'high', and 'xhigh'.",
      "title": "Reasoning Effort"
    },
    "response_format": {
      "anyOf": [
        {
          "$ref": "#/$defs/ResponseFormatText"
        },
        {
          "$ref": "#/$defs/ResponseFormatJsonObject"
        },
        {
          "$ref": "#/$defs/ResponseFormatJsonSchema"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An object specifying the format that the model must output. Setting to json_schema enables Structured Outputs.",
      "title": "Response Format"
    },
    "seed": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "If specified, the system will make a best effort to sample deterministically for reproducible results.",
      "title": "Seed"
    },
    "stream": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "If set to true, partial message deltas will be sent as server-sent events.",
      "title": "Stream"
    },
    "temperature": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "What sampling temperature to use, between 0 and 2. Higher values make output more random.",
      "title": "Temperature"
    },
    "tools": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/FunctionTool"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A list of tools the model may call. Currently, only functions are supported as a tool.",
      "title": "Tools"
    },
    "top_p": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An alternative to sampling with temperature, called nucleus sampling. Use 0.1 for top 10% probability mass.",
      "title": "Top P"
    }
  },
  "required": [
    "messages",
    "model"
  ],
  "title": "ChatCompletionRequest",
  "type": "object"
}

Fields:

messages pydantic-field

messages: list[Message]

A list of messages comprising the conversation so far.

model pydantic-field

model: str

Model ID used to generate the response, like 'gpt-4o' or 'o3'.

reasoning_effort pydantic-field

reasoning_effort: ReasoningEffort | None = None

Constrains effort on reasoning for reasoning models. Supported values are 'none', 'minimal', 'low', 'medium', 'high', and 'xhigh'.

response_format pydantic-field

response_format: ResponseFormat | None = None

An object specifying the format that the model must output. Setting to json_schema enables Structured Outputs.

seed pydantic-field

seed: int | None = None

If specified, the system will make a best effort to sample deterministically for reproducible results.

stream pydantic-field

stream: bool | None = None

If set to true, partial message deltas will be sent as server-sent events.

temperature pydantic-field

temperature: float | None = None

What sampling temperature to use, between 0 and 2. Higher values make output more random.

tools pydantic-field

tools: list[Tool] | None = None

A list of tools the model may call. Currently, only functions are supported as a tool.

top_p pydantic-field

top_p: float | None = None

An alternative to sampling with temperature, called nucleus sampling. Use 0.1 for top 10% probability mass.

Message module-attribute

Message = (
    DeveloperMessage
    | SystemMessage
    | UserMessage
    | AssistantMessage
    | ToolMessage
    | FunctionMessage
)

SystemMessage pydantic-model

System message.

Show JSON schema:
{
  "$defs": {
    "ContentPartText": {
      "description": "Text content part.",
      "properties": {
        "type": {
          "const": "text",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "text": {
          "description": "The text content.",
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "type",
        "text"
      ],
      "title": "ContentPartText",
      "type": "object"
    }
  },
  "description": "System message.",
  "properties": {
    "role": {
      "const": "system",
      "description": "The role of the messages author, in this case 'system'.",
      "title": "Role",
      "type": "string"
    },
    "content": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "$ref": "#/$defs/ContentPartText"
          },
          "type": "array"
        }
      ],
      "description": "The contents of the system message.",
      "title": "Content"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
      "title": "Name"
    }
  },
  "required": [
    "role",
    "content"
  ],
  "title": "SystemMessage",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

role pydantic-field

role: Literal['system']

The role of the messages author, in this case 'system'.

content pydantic-field

content: str | list[ContentPartText]

The contents of the system message.

name pydantic-field

name: str | None = None

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

UserMessage pydantic-model

User message.

Show JSON schema:
{
  "$defs": {
    "ContentPartFile": {
      "description": "File content part.",
      "properties": {
        "type": {
          "const": "file",
          "description": "The type of the content part. Always 'file'.",
          "title": "Type",
          "type": "string"
        },
        "file": {
          "$ref": "#/$defs/FileData",
          "description": "The file data."
        }
      },
      "required": [
        "type",
        "file"
      ],
      "title": "ContentPartFile",
      "type": "object"
    },
    "ContentPartImage": {
      "description": "Image content part.",
      "properties": {
        "type": {
          "const": "image_url",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "image_url": {
          "$ref": "#/$defs/ImageUrl",
          "description": "The image URL details."
        }
      },
      "required": [
        "type",
        "image_url"
      ],
      "title": "ContentPartImage",
      "type": "object"
    },
    "ContentPartInputAudio": {
      "description": "Input audio content part.",
      "properties": {
        "type": {
          "const": "input_audio",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "input_audio": {
          "$ref": "#/$defs/InputAudioData",
          "description": "The input audio data."
        }
      },
      "required": [
        "type",
        "input_audio"
      ],
      "title": "ContentPartInputAudio",
      "type": "object"
    },
    "ContentPartText": {
      "description": "Text content part.",
      "properties": {
        "type": {
          "const": "text",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "text": {
          "description": "The text content.",
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "type",
        "text"
      ],
      "title": "ContentPartText",
      "type": "object"
    },
    "FileData": {
      "description": "File data.",
      "properties": {
        "file_data": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The base64 encoded file data, used when passing the file to the model as a string.",
          "title": "File Data"
        },
        "file_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The ID of an uploaded file to use as input.",
          "title": "File Id"
        },
        "filename": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The name of the file, used when passing the file to the model as a string.",
          "title": "Filename"
        }
      },
      "title": "FileData",
      "type": "object"
    },
    "ImageUrl": {
      "description": "Image URL details.",
      "properties": {
        "url": {
          "description": "Either a URL of the image or the base64 encoded image data.",
          "title": "Url",
          "type": "string"
        },
        "detail": {
          "anyOf": [
            {
              "enum": [
                "auto",
                "low",
                "high"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Specifies the detail level of the image. 'low', 'high', or 'auto' for automatic selection.",
          "title": "Detail"
        }
      },
      "required": [
        "url"
      ],
      "title": "ImageUrl",
      "type": "object"
    },
    "InputAudioData": {
      "description": "Input audio data.",
      "properties": {
        "data": {
          "description": "Base64 encoded audio data.",
          "title": "Data",
          "type": "string"
        },
        "format": {
          "description": "The format of the audio data.",
          "enum": [
            "wav",
            "mp3"
          ],
          "title": "Format",
          "type": "string"
        }
      },
      "required": [
        "data",
        "format"
      ],
      "title": "InputAudioData",
      "type": "object"
    }
  },
  "description": "User message.",
  "properties": {
    "role": {
      "const": "user",
      "description": "The role of the messages author, in this case 'user'.",
      "title": "Role",
      "type": "string"
    },
    "content": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/ContentPartText"
              },
              {
                "$ref": "#/$defs/ContentPartImage"
              },
              {
                "$ref": "#/$defs/ContentPartInputAudio"
              },
              {
                "$ref": "#/$defs/ContentPartFile"
              }
            ]
          },
          "type": "array"
        }
      ],
      "description": "The contents of the user message.",
      "title": "Content"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
      "title": "Name"
    }
  },
  "required": [
    "role",
    "content"
  ],
  "title": "UserMessage",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

role pydantic-field

role: Literal['user']

The role of the messages author, in this case 'user'.

content pydantic-field

content: str | list[ContentPart]

The contents of the user message.

name pydantic-field

name: str | None = None

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

AssistantMessage pydantic-model

Assistant message.

Show JSON schema:
{
  "$defs": {
    "AssistantMessageAudio": {
      "description": "Audio reference in assistant message.",
      "properties": {
        "id": {
          "description": "Unique identifier for a previous audio response from the model.",
          "title": "Id",
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "title": "AssistantMessageAudio",
      "type": "object"
    },
    "ContentPartRefusal": {
      "description": "Refusal content part.",
      "properties": {
        "type": {
          "const": "refusal",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "refusal": {
          "description": "The refusal message.",
          "title": "Refusal",
          "type": "string"
        }
      },
      "required": [
        "type",
        "refusal"
      ],
      "title": "ContentPartRefusal",
      "type": "object"
    },
    "ContentPartText": {
      "description": "Text content part.",
      "properties": {
        "type": {
          "const": "text",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "text": {
          "description": "The text content.",
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "type",
        "text"
      ],
      "title": "ContentPartText",
      "type": "object"
    },
    "FunctionCallResult": {
      "description": "Function call result in assistant message.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "FunctionCallResult",
      "type": "object"
    },
    "ToolCall": {
      "description": "Tool call in assistant message.",
      "properties": {
        "id": {
          "description": "The ID of the tool call.",
          "title": "Id",
          "type": "string"
        },
        "type": {
          "const": "function",
          "description": "The type of the tool. Currently, only 'function' is supported.",
          "title": "Type",
          "type": "string"
        },
        "function": {
          "$ref": "#/$defs/ToolCallFunction",
          "description": "The function that the model called."
        }
      },
      "required": [
        "id",
        "type",
        "function"
      ],
      "title": "ToolCall",
      "type": "object"
    },
    "ToolCallFunction": {
      "description": "Function details in tool call.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "ToolCallFunction",
      "type": "object"
    }
  },
  "description": "Assistant message.",
  "properties": {
    "role": {
      "const": "assistant",
      "description": "The role of the messages author, in this case 'assistant'.",
      "title": "Role",
      "type": "string"
    },
    "content": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/ContentPartText"
              },
              {
                "$ref": "#/$defs/ContentPartRefusal"
              }
            ]
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The contents of the assistant message. Required unless tool_calls or function_call is specified.",
      "title": "Content"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
      "title": "Name"
    },
    "refusal": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The refusal message by the assistant.",
      "title": "Refusal"
    },
    "audio": {
      "anyOf": [
        {
          "$ref": "#/$defs/AssistantMessageAudio"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Data about a previous audio response from the model."
    },
    "tool_calls": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ToolCall"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The tool calls generated by the model, such as function calls.",
      "title": "Tool Calls"
    },
    "function_call": {
      "anyOf": [
        {
          "$ref": "#/$defs/FunctionCallResult"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Deprecated and replaced by tool_calls. The name and arguments of a function that should be called."
    }
  },
  "required": [
    "role"
  ],
  "title": "AssistantMessage",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

role pydantic-field

role: Literal['assistant']

The role of the messages author, in this case 'assistant'.

content pydantic-field

content: str | list[ContentPartText | ContentPartRefusal] | None = None

The contents of the assistant message. Required unless tool_calls or function_call is specified.

name pydantic-field

name: str | None = None

An optional name for the participant. Provides the model information to differentiate between participants of the same role.

refusal pydantic-field

refusal: str | None = None

The refusal message by the assistant.

audio pydantic-field

audio: AssistantMessageAudio | None = None

Data about a previous audio response from the model.

tool_calls pydantic-field

tool_calls: list[ToolCall] | None = None

The tool calls generated by the model, such as function calls.

function_call pydantic-field

function_call: FunctionCallResult | None = None

Deprecated and replaced by tool_calls. The name and arguments of a function that should be called.

ToolMessage pydantic-model

Tool message.

Show JSON schema:
{
  "$defs": {
    "ContentPartText": {
      "description": "Text content part.",
      "properties": {
        "type": {
          "const": "text",
          "description": "The type of the content part.",
          "title": "Type",
          "type": "string"
        },
        "text": {
          "description": "The text content.",
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "type",
        "text"
      ],
      "title": "ContentPartText",
      "type": "object"
    }
  },
  "description": "Tool message.",
  "properties": {
    "role": {
      "const": "tool",
      "description": "The role of the messages author, in this case 'tool'.",
      "title": "Role",
      "type": "string"
    },
    "content": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "$ref": "#/$defs/ContentPartText"
          },
          "type": "array"
        }
      ],
      "description": "The contents of the tool message.",
      "title": "Content"
    },
    "tool_call_id": {
      "description": "Tool call that this message is responding to.",
      "title": "Tool Call Id",
      "type": "string"
    }
  },
  "required": [
    "role",
    "content",
    "tool_call_id"
  ],
  "title": "ToolMessage",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

role pydantic-field

role: Literal['tool']

The role of the messages author, in this case 'tool'.

content pydantic-field

content: str | list[ContentPartText]

The contents of the tool message.

tool_call_id pydantic-field

tool_call_id: str

Tool call that this message is responding to.

Tool module-attribute

Tool = FunctionTool

FunctionDefinition pydantic-model

Function definition for tools.

Show JSON schema:
{
  "description": "Function definition for tools.",
  "properties": {
    "name": {
      "description": "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.",
      "title": "Name",
      "type": "string"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A description of what the function does, used by the model to choose when and how to call the function.",
      "title": "Description"
    },
    "parameters": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The parameters the functions accepts, described as a JSON Schema object.",
      "title": "Parameters"
    },
    "strict": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Whether to enable strict schema adherence when generating the function call.",
      "title": "Strict"
    }
  },
  "required": [
    "name"
  ],
  "title": "FunctionDefinition",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

name pydantic-field

name: str

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

description pydantic-field

description: str | None = None

A description of what the function does, used by the model to choose when and how to call the function.

parameters pydantic-field

parameters: dict[str, Any] | None = None

The parameters the functions accepts, described as a JSON Schema object.

strict pydantic-field

strict: bool | None = None

Whether to enable strict schema adherence when generating the function call.

ResponseFormat module-attribute

ResponseFormat = (
    ResponseFormatText | ResponseFormatJsonObject | ResponseFormatJsonSchema
)

ChatCompletionResponse pydantic-model

OpenAI Chat Completion response.

This is a Pydantic model representation of the OpenAI chat completion response.

Show JSON schema:
{
  "$defs": {
    "Annotation": {
      "description": "Annotation in message.",
      "properties": {
        "type": {
          "const": "url_citation",
          "description": "The type of the URL citation. Always 'url_citation'.",
          "title": "Type",
          "type": "string"
        },
        "url_citation": {
          "$ref": "#/$defs/AnnotationUrlCitation",
          "description": "A URL citation when using web search."
        }
      },
      "required": [
        "type",
        "url_citation"
      ],
      "title": "Annotation",
      "type": "object"
    },
    "AnnotationUrlCitation": {
      "description": "URL citation annotation.",
      "properties": {
        "end_index": {
          "description": "The index of the last character of the URL citation in the message.",
          "title": "End Index",
          "type": "integer"
        },
        "start_index": {
          "description": "The index of the first character of the URL citation in the message.",
          "title": "Start Index",
          "type": "integer"
        },
        "title": {
          "description": "The title of the web resource.",
          "title": "Title",
          "type": "string"
        },
        "url": {
          "description": "The URL of the web resource.",
          "title": "Url",
          "type": "string"
        }
      },
      "required": [
        "end_index",
        "start_index",
        "title",
        "url"
      ],
      "title": "AnnotationUrlCitation",
      "type": "object"
    },
    "AudioResponse": {
      "description": "Audio response from the model.",
      "properties": {
        "id": {
          "description": "Unique identifier for this audio response.",
          "title": "Id",
          "type": "string"
        },
        "data": {
          "description": "Base64 encoded audio bytes generated by the model, in the format specified in the request.",
          "title": "Data",
          "type": "string"
        },
        "expires_at": {
          "description": "The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server.",
          "title": "Expires At",
          "type": "integer"
        },
        "transcript": {
          "description": "Transcript of the audio generated by the model.",
          "title": "Transcript",
          "type": "string"
        }
      },
      "required": [
        "id",
        "data",
        "expires_at",
        "transcript"
      ],
      "title": "AudioResponse",
      "type": "object"
    },
    "Choice": {
      "description": "A chat completion choice.",
      "properties": {
        "finish_reason": {
          "anyOf": [
            {
              "enum": [
                "stop",
                "length",
                "tool_calls",
                "content_filter",
                "function_call",
                "error"
              ],
              "type": "string"
            },
            {
              "type": "string"
            }
          ],
          "description": "The reason the model stopped generating tokens. 'stop' for natural stop, 'length' for max tokens, 'tool_calls' for tool call, 'content_filter' for content filter, 'function_call' (deprecated) for function call, 'error' if an error occurred.",
          "title": "Finish Reason"
        },
        "index": {
          "description": "The index of the choice in the list of choices.",
          "title": "Index",
          "type": "integer"
        },
        "message": {
          "$ref": "#/$defs/ResponseMessage"
        },
        "logprobs": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChoiceLogprobs"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Log probability information for the choice."
        }
      },
      "required": [
        "finish_reason",
        "index",
        "message"
      ],
      "title": "Choice",
      "type": "object"
    },
    "ChoiceLogprobs": {
      "description": "Log probability information for a choice.",
      "properties": {
        "content": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/TokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of message content tokens with log probability information.",
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/TokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of message refusal tokens with log probability information.",
          "title": "Refusal"
        }
      },
      "title": "ChoiceLogprobs",
      "type": "object"
    },
    "CompletionUsage": {
      "description": "Usage statistics for the completion request.",
      "properties": {
        "completion_tokens": {
          "description": "Number of tokens in the generated completion.",
          "title": "Completion Tokens",
          "type": "integer"
        },
        "prompt_tokens": {
          "description": "Number of tokens in the prompt.",
          "title": "Prompt Tokens",
          "type": "integer"
        },
        "total_tokens": {
          "description": "Total number of tokens used in the request (prompt + completion).",
          "title": "Total Tokens",
          "type": "integer"
        }
      },
      "required": [
        "completion_tokens",
        "prompt_tokens",
        "total_tokens"
      ],
      "title": "CompletionUsage",
      "type": "object"
    },
    "ResponseMessage": {
      "description": "A chat completion message generated by the model.",
      "properties": {
        "role": {
          "const": "assistant",
          "description": "The role of the author of this message.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The contents of the message.",
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The refusal message generated by the model.",
          "title": "Refusal"
        },
        "annotations": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Annotation"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Annotations for the message, when applicable, as when using the web search tool.",
          "title": "Annotations"
        },
        "audio": {
          "anyOf": [
            {
              "$ref": "#/$defs/AudioResponse"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "If the audio output modality is requested, this object contains data about the audio response from the model."
        },
        "tool_calls": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/ResponseToolCall"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The tool calls generated by the model, such as function calls.",
          "title": "Tool Calls"
        }
      },
      "required": [
        "role"
      ],
      "title": "ResponseMessage",
      "type": "object"
    },
    "ResponseToolCall": {
      "description": "Tool call in assistant message.",
      "properties": {
        "id": {
          "description": "The ID of the tool call.",
          "title": "Id",
          "type": "string"
        },
        "type": {
          "const": "function",
          "description": "The type of the tool. Currently, only 'function' is supported.",
          "title": "Type",
          "type": "string"
        },
        "function": {
          "$ref": "#/$defs/ToolCallFunction",
          "description": "The function that the model called."
        }
      },
      "required": [
        "id",
        "type",
        "function"
      ],
      "title": "ResponseToolCall",
      "type": "object"
    },
    "TokenLogprob": {
      "description": "Token log probability information.",
      "properties": {
        "token": {
          "description": "The token.",
          "title": "Token",
          "type": "string"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of integers representing the UTF-8 bytes representation of the token.",
          "title": "Bytes"
        },
        "logprob": {
          "description": "The log probability of this token, if it is within the top 20 most likely tokens.",
          "title": "Logprob",
          "type": "number"
        },
        "top_logprobs": {
          "description": "List of the most likely tokens and their log probability, at this token position.",
          "items": {
            "$ref": "#/$defs/TopLogprob"
          },
          "title": "Top Logprobs",
          "type": "array"
        }
      },
      "required": [
        "token",
        "logprob",
        "top_logprobs"
      ],
      "title": "TokenLogprob",
      "type": "object"
    },
    "ToolCallFunction": {
      "description": "Function details in tool call.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "ToolCallFunction",
      "type": "object"
    },
    "TopLogprob": {
      "description": "Top logprob entry.",
      "properties": {
        "token": {
          "description": "The token.",
          "title": "Token",
          "type": "string"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of integers representing the UTF-8 bytes representation of the token.",
          "title": "Bytes"
        },
        "logprob": {
          "description": "The log probability of this token, if it is within the top 20 most likely tokens.",
          "title": "Logprob",
          "type": "number"
        }
      },
      "required": [
        "token",
        "logprob"
      ],
      "title": "TopLogprob",
      "type": "object"
    }
  },
  "description": "OpenAI Chat Completion response.\n\nThis is a Pydantic model representation of the OpenAI chat completion response.",
  "properties": {
    "id": {
      "description": "A unique identifier for the chat completion.",
      "title": "Id",
      "type": "string"
    },
    "choices": {
      "description": "A list of chat completion choices. Can be more than one if 'n' is greater than 1.",
      "items": {
        "$ref": "#/$defs/Choice"
      },
      "title": "Choices",
      "type": "array"
    },
    "created": {
      "description": "The Unix timestamp (in seconds) of when the chat completion was created.",
      "title": "Created",
      "type": "integer"
    },
    "model": {
      "description": "The model used for the chat completion.",
      "title": "Model",
      "type": "string"
    },
    "object": {
      "const": "chat.completion",
      "description": "The object type, which is always 'chat.completion'.",
      "title": "Object",
      "type": "string"
    },
    "usage": {
      "anyOf": [
        {
          "$ref": "#/$defs/CompletionUsage"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Usage statistics for the completion request."
    },
    "session_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The session ID associated with this chat completion, if applicable.",
      "title": "Session Id"
    }
  },
  "required": [
    "id",
    "choices",
    "created",
    "model",
    "object"
  ],
  "title": "ChatCompletionResponse",
  "type": "object"
}

Fields:

id pydantic-field

id: str

A unique identifier for the chat completion.

choices pydantic-field

choices: list[Choice]

A list of chat completion choices. Can be more than one if 'n' is greater than 1.

created pydantic-field

created: int

The Unix timestamp (in seconds) of when the chat completion was created.

model pydantic-field

model: str

The model used for the chat completion.

object pydantic-field

object: Literal['chat.completion']

The object type, which is always 'chat.completion'.

usage pydantic-field

usage: CompletionUsage | None = None

Usage statistics for the completion request.

session_id pydantic-field

session_id: str | None = None

The session ID associated with this chat completion, if applicable.

Choice pydantic-model

A chat completion choice.

Show JSON schema:
{
  "$defs": {
    "Annotation": {
      "description": "Annotation in message.",
      "properties": {
        "type": {
          "const": "url_citation",
          "description": "The type of the URL citation. Always 'url_citation'.",
          "title": "Type",
          "type": "string"
        },
        "url_citation": {
          "$ref": "#/$defs/AnnotationUrlCitation",
          "description": "A URL citation when using web search."
        }
      },
      "required": [
        "type",
        "url_citation"
      ],
      "title": "Annotation",
      "type": "object"
    },
    "AnnotationUrlCitation": {
      "description": "URL citation annotation.",
      "properties": {
        "end_index": {
          "description": "The index of the last character of the URL citation in the message.",
          "title": "End Index",
          "type": "integer"
        },
        "start_index": {
          "description": "The index of the first character of the URL citation in the message.",
          "title": "Start Index",
          "type": "integer"
        },
        "title": {
          "description": "The title of the web resource.",
          "title": "Title",
          "type": "string"
        },
        "url": {
          "description": "The URL of the web resource.",
          "title": "Url",
          "type": "string"
        }
      },
      "required": [
        "end_index",
        "start_index",
        "title",
        "url"
      ],
      "title": "AnnotationUrlCitation",
      "type": "object"
    },
    "AudioResponse": {
      "description": "Audio response from the model.",
      "properties": {
        "id": {
          "description": "Unique identifier for this audio response.",
          "title": "Id",
          "type": "string"
        },
        "data": {
          "description": "Base64 encoded audio bytes generated by the model, in the format specified in the request.",
          "title": "Data",
          "type": "string"
        },
        "expires_at": {
          "description": "The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server.",
          "title": "Expires At",
          "type": "integer"
        },
        "transcript": {
          "description": "Transcript of the audio generated by the model.",
          "title": "Transcript",
          "type": "string"
        }
      },
      "required": [
        "id",
        "data",
        "expires_at",
        "transcript"
      ],
      "title": "AudioResponse",
      "type": "object"
    },
    "ChoiceLogprobs": {
      "description": "Log probability information for a choice.",
      "properties": {
        "content": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/TokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of message content tokens with log probability information.",
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/TokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of message refusal tokens with log probability information.",
          "title": "Refusal"
        }
      },
      "title": "ChoiceLogprobs",
      "type": "object"
    },
    "ResponseMessage": {
      "description": "A chat completion message generated by the model.",
      "properties": {
        "role": {
          "const": "assistant",
          "description": "The role of the author of this message.",
          "title": "Role",
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The contents of the message.",
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The refusal message generated by the model.",
          "title": "Refusal"
        },
        "annotations": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Annotation"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Annotations for the message, when applicable, as when using the web search tool.",
          "title": "Annotations"
        },
        "audio": {
          "anyOf": [
            {
              "$ref": "#/$defs/AudioResponse"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "If the audio output modality is requested, this object contains data about the audio response from the model."
        },
        "tool_calls": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/ResponseToolCall"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The tool calls generated by the model, such as function calls.",
          "title": "Tool Calls"
        }
      },
      "required": [
        "role"
      ],
      "title": "ResponseMessage",
      "type": "object"
    },
    "ResponseToolCall": {
      "description": "Tool call in assistant message.",
      "properties": {
        "id": {
          "description": "The ID of the tool call.",
          "title": "Id",
          "type": "string"
        },
        "type": {
          "const": "function",
          "description": "The type of the tool. Currently, only 'function' is supported.",
          "title": "Type",
          "type": "string"
        },
        "function": {
          "$ref": "#/$defs/ToolCallFunction",
          "description": "The function that the model called."
        }
      },
      "required": [
        "id",
        "type",
        "function"
      ],
      "title": "ResponseToolCall",
      "type": "object"
    },
    "TokenLogprob": {
      "description": "Token log probability information.",
      "properties": {
        "token": {
          "description": "The token.",
          "title": "Token",
          "type": "string"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of integers representing the UTF-8 bytes representation of the token.",
          "title": "Bytes"
        },
        "logprob": {
          "description": "The log probability of this token, if it is within the top 20 most likely tokens.",
          "title": "Logprob",
          "type": "number"
        },
        "top_logprobs": {
          "description": "List of the most likely tokens and their log probability, at this token position.",
          "items": {
            "$ref": "#/$defs/TopLogprob"
          },
          "title": "Top Logprobs",
          "type": "array"
        }
      },
      "required": [
        "token",
        "logprob",
        "top_logprobs"
      ],
      "title": "TokenLogprob",
      "type": "object"
    },
    "ToolCallFunction": {
      "description": "Function details in tool call.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "ToolCallFunction",
      "type": "object"
    },
    "TopLogprob": {
      "description": "Top logprob entry.",
      "properties": {
        "token": {
          "description": "The token.",
          "title": "Token",
          "type": "string"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A list of integers representing the UTF-8 bytes representation of the token.",
          "title": "Bytes"
        },
        "logprob": {
          "description": "The log probability of this token, if it is within the top 20 most likely tokens.",
          "title": "Logprob",
          "type": "number"
        }
      },
      "required": [
        "token",
        "logprob"
      ],
      "title": "TopLogprob",
      "type": "object"
    }
  },
  "description": "A chat completion choice.",
  "properties": {
    "finish_reason": {
      "anyOf": [
        {
          "enum": [
            "stop",
            "length",
            "tool_calls",
            "content_filter",
            "function_call",
            "error"
          ],
          "type": "string"
        },
        {
          "type": "string"
        }
      ],
      "description": "The reason the model stopped generating tokens. 'stop' for natural stop, 'length' for max tokens, 'tool_calls' for tool call, 'content_filter' for content filter, 'function_call' (deprecated) for function call, 'error' if an error occurred.",
      "title": "Finish Reason"
    },
    "index": {
      "description": "The index of the choice in the list of choices.",
      "title": "Index",
      "type": "integer"
    },
    "message": {
      "$ref": "#/$defs/ResponseMessage"
    },
    "logprobs": {
      "anyOf": [
        {
          "$ref": "#/$defs/ChoiceLogprobs"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Log probability information for the choice."
    }
  },
  "required": [
    "finish_reason",
    "index",
    "message"
  ],
  "title": "Choice",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

finish_reason pydantic-field

finish_reason: (
    Literal["stop", "length", "tool_calls", "content_filter", "function_call", "error"]
    | str
)

The reason the model stopped generating tokens. 'stop' for natural stop, 'length' for max tokens, 'tool_calls' for tool call, 'content_filter' for content filter, 'function_call' (deprecated) for function call, 'error' if an error occurred.

index pydantic-field

index: int

The index of the choice in the list of choices.

message pydantic-field

message: ResponseMessage

A chat completion message generated by the model.

logprobs pydantic-field

logprobs: ChoiceLogprobs | None = None

Log probability information for the choice.

ResponseMessage pydantic-model

A chat completion message generated by the model.

Show JSON schema:
{
  "$defs": {
    "Annotation": {
      "description": "Annotation in message.",
      "properties": {
        "type": {
          "const": "url_citation",
          "description": "The type of the URL citation. Always 'url_citation'.",
          "title": "Type",
          "type": "string"
        },
        "url_citation": {
          "$ref": "#/$defs/AnnotationUrlCitation",
          "description": "A URL citation when using web search."
        }
      },
      "required": [
        "type",
        "url_citation"
      ],
      "title": "Annotation",
      "type": "object"
    },
    "AnnotationUrlCitation": {
      "description": "URL citation annotation.",
      "properties": {
        "end_index": {
          "description": "The index of the last character of the URL citation in the message.",
          "title": "End Index",
          "type": "integer"
        },
        "start_index": {
          "description": "The index of the first character of the URL citation in the message.",
          "title": "Start Index",
          "type": "integer"
        },
        "title": {
          "description": "The title of the web resource.",
          "title": "Title",
          "type": "string"
        },
        "url": {
          "description": "The URL of the web resource.",
          "title": "Url",
          "type": "string"
        }
      },
      "required": [
        "end_index",
        "start_index",
        "title",
        "url"
      ],
      "title": "AnnotationUrlCitation",
      "type": "object"
    },
    "AudioResponse": {
      "description": "Audio response from the model.",
      "properties": {
        "id": {
          "description": "Unique identifier for this audio response.",
          "title": "Id",
          "type": "string"
        },
        "data": {
          "description": "Base64 encoded audio bytes generated by the model, in the format specified in the request.",
          "title": "Data",
          "type": "string"
        },
        "expires_at": {
          "description": "The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server.",
          "title": "Expires At",
          "type": "integer"
        },
        "transcript": {
          "description": "Transcript of the audio generated by the model.",
          "title": "Transcript",
          "type": "string"
        }
      },
      "required": [
        "id",
        "data",
        "expires_at",
        "transcript"
      ],
      "title": "AudioResponse",
      "type": "object"
    },
    "ResponseToolCall": {
      "description": "Tool call in assistant message.",
      "properties": {
        "id": {
          "description": "The ID of the tool call.",
          "title": "Id",
          "type": "string"
        },
        "type": {
          "const": "function",
          "description": "The type of the tool. Currently, only 'function' is supported.",
          "title": "Type",
          "type": "string"
        },
        "function": {
          "$ref": "#/$defs/ToolCallFunction",
          "description": "The function that the model called."
        }
      },
      "required": [
        "id",
        "type",
        "function"
      ],
      "title": "ResponseToolCall",
      "type": "object"
    },
    "ToolCallFunction": {
      "description": "Function details in tool call.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "ToolCallFunction",
      "type": "object"
    }
  },
  "description": "A chat completion message generated by the model.",
  "properties": {
    "role": {
      "const": "assistant",
      "description": "The role of the author of this message.",
      "title": "Role",
      "type": "string"
    },
    "content": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The contents of the message.",
      "title": "Content"
    },
    "refusal": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The refusal message generated by the model.",
      "title": "Refusal"
    },
    "annotations": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/Annotation"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Annotations for the message, when applicable, as when using the web search tool.",
      "title": "Annotations"
    },
    "audio": {
      "anyOf": [
        {
          "$ref": "#/$defs/AudioResponse"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "If the audio output modality is requested, this object contains data about the audio response from the model."
    },
    "tool_calls": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ResponseToolCall"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The tool calls generated by the model, such as function calls.",
      "title": "Tool Calls"
    }
  },
  "required": [
    "role"
  ],
  "title": "ResponseMessage",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

role pydantic-field

role: Literal['assistant']

The role of the author of this message.

content pydantic-field

content: str | None = None

The contents of the message.

refusal pydantic-field

refusal: str | None = None

The refusal message generated by the model.

annotations pydantic-field

annotations: list[Annotation] | None = None

Annotations for the message, when applicable, as when using the web search tool.

audio pydantic-field

audio: AudioResponse | None = None

If the audio output modality is requested, this object contains data about the audio response from the model.

tool_calls pydantic-field

tool_calls: list[ResponseToolCall] | None = None

The tool calls generated by the model, such as function calls.

ResponseToolCall pydantic-model

Tool call in assistant message.

Show JSON schema:
{
  "$defs": {
    "ToolCallFunction": {
      "description": "Function details in tool call.",
      "properties": {
        "arguments": {
          "description": "The arguments to call the function with, as generated by the model in JSON format.",
          "title": "Arguments",
          "type": "string"
        },
        "name": {
          "description": "The name of the function to call.",
          "title": "Name",
          "type": "string"
        }
      },
      "required": [
        "arguments",
        "name"
      ],
      "title": "ToolCallFunction",
      "type": "object"
    }
  },
  "description": "Tool call in assistant message.",
  "properties": {
    "id": {
      "description": "The ID of the tool call.",
      "title": "Id",
      "type": "string"
    },
    "type": {
      "const": "function",
      "description": "The type of the tool. Currently, only 'function' is supported.",
      "title": "Type",
      "type": "string"
    },
    "function": {
      "$ref": "#/$defs/ToolCallFunction",
      "description": "The function that the model called."
    }
  },
  "required": [
    "id",
    "type",
    "function"
  ],
  "title": "ResponseToolCall",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

id pydantic-field

id: str

The ID of the tool call.

type pydantic-field

type: Literal['function']

The type of the tool. Currently, only 'function' is supported.

function pydantic-field

function: ToolCallFunction

The function that the model called.

CompletionUsage pydantic-model

Usage statistics for the completion request.

Show JSON schema:
{
  "description": "Usage statistics for the completion request.",
  "properties": {
    "completion_tokens": {
      "description": "Number of tokens in the generated completion.",
      "title": "Completion Tokens",
      "type": "integer"
    },
    "prompt_tokens": {
      "description": "Number of tokens in the prompt.",
      "title": "Prompt Tokens",
      "type": "integer"
    },
    "total_tokens": {
      "description": "Total number of tokens used in the request (prompt + completion).",
      "title": "Total Tokens",
      "type": "integer"
    }
  },
  "required": [
    "completion_tokens",
    "prompt_tokens",
    "total_tokens"
  ],
  "title": "CompletionUsage",
  "type": "object"
}

Config:

  • extra: ignore

Fields:

completion_tokens pydantic-field

completion_tokens: int

Number of tokens in the generated completion.

prompt_tokens pydantic-field

prompt_tokens: int

Number of tokens in the prompt.

total_tokens pydantic-field

total_tokens: int

Total number of tokens used in the request (prompt + completion).


Result Schema

When using Dual-LLM mode, the response content follows ResponseContentJsonSchema.

ResponseContentJsonSchema pydantic-model

Response content of a dual-LLM session.

Parses the content field of the assistant message returned by Sequrity Control in dual-LLM mode. The JSON looks like::

{
    "status": "success",
    "final_return_value": {"value": "...", "meta": {...}},
    "program": "...",
    ...
}

Use :meth:parse_json_safe for lenient parsing that never raises.

Show JSON schema:
{
  "$defs": {
    "ErrorInfo": {
      "description": "Represents error information in a dual-LLM response.\n\nWhen the server serialises an error for the user, it simplifies the\ninternal ``StateExecutionError`` into this flat structure.",
      "properties": {
        "code": {
          "title": "Code",
          "type": "string"
        },
        "message": {
          "title": "Message",
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "title": "ErrorInfo",
      "type": "object"
    },
    "MetaData": {
      "additionalProperties": false,
      "description": "Metadata associated with a value for Sequrity Control's policy enforcement system.\n\nEvery value flowing through the dual-LLM interpreter carries metadata that\nrecords *who* produced it, *who* may consume it, and arbitrary *tags* for\npolicy matching.",
      "properties": {
        "producers": {
          "items": {
            "type": "string"
          },
          "title": "Producers",
          "type": "array",
          "uniqueItems": true
        },
        "consumers": {
          "items": {
            "type": "string"
          },
          "title": "Consumers",
          "type": "array",
          "uniqueItems": true
        },
        "tags": {
          "items": {
            "type": "string"
          },
          "title": "Tags",
          "type": "array",
          "uniqueItems": true
        }
      },
      "title": "MetaData",
      "type": "object"
    },
    "ValueWithMeta": {
      "description": "Python value wrapper with metadata for Sequrity Control's policy enforcement system.",
      "properties": {
        "value": {
          "title": "Value"
        },
        "meta": {
          "$ref": "#/$defs/MetaData"
        }
      },
      "required": [
        "value"
      ],
      "title": "ValueWithMeta",
      "type": "object"
    }
  },
  "additionalProperties": true,
  "description": "Response content of a dual-LLM session.\n\nParses the ``content`` field of the assistant message returned by\nSequrity Control in dual-LLM mode.  The JSON looks like::\n\n    {\n        \"status\": \"success\",\n        \"final_return_value\": {\"value\": \"...\", \"meta\": {...}},\n        \"program\": \"...\",\n        ...\n    }\n\nUse :meth:`parse_json_safe` for lenient parsing that never raises.",
  "properties": {
    "status": {
      "enum": [
        "success",
        "failure",
        "unknown"
      ],
      "title": "Status",
      "type": "string"
    },
    "final_return_value": {
      "anyOf": [
        {
          "$ref": "#/$defs/ValueWithMeta"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "error": {
      "anyOf": [
        {
          "$ref": "#/$defs/ErrorInfo"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "program": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Program"
    },
    "namespace_snapshot": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/ValueWithMeta"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Namespace Snapshot"
    },
    "session_meta": {
      "anyOf": [
        {
          "$ref": "#/$defs/ValueWithMeta"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "policy_check_history": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Policy Check History"
    },
    "message_history_mismatch_detected": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Message History Mismatch Detected"
    },
    "raw": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Raw"
    }
  },
  "required": [
    "status"
  ],
  "title": "ResponseContentJsonSchema",
  "type": "object"
}

Config:

  • extra: allow

Fields:

parse_json_safe classmethod

parse_json_safe(data: str) -> ResponseContentJsonSchema

Parse JSON data safely, returning an unknown status if parsing fails.

Source code in src/sequrity/control/types/dual_llm_response.py
@classmethod
def parse_json_safe(cls, data: str) -> ResponseContentJsonSchema:
    """Parse JSON data safely, returning an ``unknown`` status if parsing fails."""
    try:
        validated = cls.model_validate_json(data)
    except Exception:
        validated = cls(status="unknown", raw=data)
    return validated

ErrorInfo pydantic-model

Represents error information in a dual-LLM response.

When the server serialises an error for the user, it simplifies the internal StateExecutionError into this flat structure.

Show JSON schema:
{
  "description": "Represents error information in a dual-LLM response.\n\nWhen the server serialises an error for the user, it simplifies the\ninternal ``StateExecutionError`` into this flat structure.",
  "properties": {
    "code": {
      "title": "Code",
      "type": "string"
    },
    "message": {
      "title": "Message",
      "type": "string"
    }
  },
  "required": [
    "code",
    "message"
  ],
  "title": "ErrorInfo",
  "type": "object"
}

Fields: