wallaroo.openapi_tmpl


WITH_OPENAI = '\nopenapi: 3.1.1\ninfo:\n title: {pipeline_name}\n description: |\n The Wallaroo Inference API allows you to perform real-time inference on deployed machine learning models and pipelines.\n \n ## OpenAI Compatibility\n \n Wallaroo provides OpenAI-compatible endpoints for seamless integration with existing OpenAI workflows:\n - **Completions API**: Text completion compatible with OpenAI\'s legacy completions API\n - **Chat Completions API**: Chat completion compatible with OpenAI\'s chat completions API\n \n ## Authentication\n \n All requests require authentication using Bearer tokens obtained through the Wallaroo platform.\n \n version: {version}\n\nservers:\n - url: {url}\n description: Wallaroo Platform API\n\npaths:\n /openai/v1/completions:\n post:\n summary: OpenAI-compatible text completion\n description: |\n OpenAI-compatible text completion endpoint. This endpoint provides the ability to use standard [OpenAI Completions API](https://platform.openai.com/docs/api-reference/completions) requests, or use the official OpenAI of compatible SDKs (e.g., lightllm) for pipelines configured to be OpenAI compatible.\n \n As this functionality is provided by the vLLM framework, the request and response schemas as outlined in the [vLLM Documentation](https://docs.vllm.ai/en/v0.6.6/serving/openai_compatible_server.html#completions-api).\n\n operationId: openaiCompletion\n tags:\n - OpenAI Compatibility\n requestBody:\n required: true\n content:\n application/json:\n examples:\n simple_completion:\n summary: Simple text completion\n description: |\n A standard [OpenAI Completion API](https://platform.openai.com/docs/api-reference/completions) request, that also supports [vLLM\'s extra parameters](https://docs.vllm.ai/en/v0.6.6/serving/openai_compatible_server.html#completions-api).\n\n The only deviation from the standard OpenAI/vLLM API is that the `model` property is optional. Its value, even if provided is ignored, since the model is determined by the pipeline.\n value:\n model: "my_pipeline"\n prompt: "The capital of France is"\n max_tokens: 50\n temperature: 0.7\n streaming_text_completion:\n summary: Text completion with Token Streaming\n description: |\n A standard [OpenAI Completions API](https://platform.openai.com/docs/api-reference/completions) request, that also supports [vLLM\'s extra parameters](https://docs.vllm.ai/en/v0.6.6/serving/openai_compatible_server.html#completions-api).\n\n The only deviation from the standard OpenAI/vLLM API is that the `model` property is optional. Its value, even if provided is ignored, since the model is determined by the pipeline.\n value:\n model: "my_pipeline"\n prompt: "The capitals of the countries of Europe are"\n max_tokens: 200\n temperature: 0.7\n stream: true\n responses:\n \'200\':\n description: Successful completion\n content:\n application/json:\n examples:\n completion_response:\n summary: Completion response\n description: |\n A standard [OpenAI Completions API](https://platform.openai.com/docs/api-reference/completions) response.\n value:\n id: "cmpl-abc123"\n object: "completion"\n created: 1677652288\n model: "my_pipeline"\n choices:\n - text: " Paris."\n index: 0\n finish_reason: "stop"\n logprobs: null\n usage:\n prompt_tokens: 5\n completion_tokens: 2\n total_tokens: 7\n \'400\':\n $ref: \'#/components/responses/BadRequest\'\n \'401\':\n $ref: \'#/components/responses/Unauthorized\'\n \'404\':\n $ref: \'#/components/responses/NotFound\'\n \'409\':\n description: Pipeline type conflict\n content:\n application/json:\n description: Pandas records format response\n schema:\n $ref: \'#/components/responses/Conflict\'\n example:\n code: 409\n status: error\n error: "Inference failed. Please apply the appropriate OpenAI configurations to the models deployed in this pipeline. For additional help contact support@wallaroo.ai or your Wallaroo technical representative."\n source: engine\n \'500\':\n $ref: \'#/components/responses/InternalServerError\'\n \'503\':\n $ref: \'#/components/responses/ServiceUnavailable\'\n\n /openai/v1/chat/completions:\n post:\n summary: OpenAI-compatible chat completion\n description: |\n OpenAI-compatible text completion endpoint. This endpoint provides the ability to use standard [OpenAI Completions API](https://platform.openai.com/docs/api-reference/chat/create) requests, or use the official OpenAI of compatible SDKs (e.g., lightllm) for pipelines configured to be OpenAI compatible.\n \n As this functionality is provided by the vLLM framework, the request and response schemas as outlined in the [vLLM Documentation](https://docs.vllm.ai/en/v0.6.6/serving/openai_compatible_server.html#chat-api).\n operationId: openaiChatCompletion\n tags:\n - OpenAI Compatibility\n requestBody:\n required: true\n content:\n application/json:\n examples:\n simple_chat:\n summary: Simple chat completion\n description: |\n A standard [OpenAI Completion API](https://platform.openai.com/docs/api-reference/chat/create) request, that also supports [vLLM\'s extra parameters](https://docs.vllm.ai/en/v0.6.6/serving/openai_compatible_server.html#chat-api).\n\n The only deviation from the standard OpenAI/vLLM API is that the `model` property is optional. Its value, even if provided is ignored, since the model is determined by the pipeline.\n value:\n model: ""\n messages:\n - role: "user"\n content: "What is the capital of France?"\n max_tokens: 50\n temperature: 0.7\n streaming_simple_chat:\n summary: Chat completion with Token Streaming\n description: |\n A standard [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat/create) request, that also supports [vLLM\'s extra parameters](https://docs.vllm.ai/en/v0.6.6/serving/openai_compatible_server.html#chat-api).\n\n The only deviation from the standard OpenAI/vLLM API is that the `model` property is optional. Its value, even if provided is ignored, since the model is determined by the pipeline.\n value:\n model: ""\n messages:\n - role: "user"\n content: "What is the capital of France?"\n max_tokens: 50\n temperature: 0.7\n stream: true\n responses:\n \'200\':\n description: Successful chat completion\n content:\n application/json:\n examples:\n chat_response:\n summary: Chat completion response\n description: |\n A standard [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat/create) response.\n value:\n id: "chatcmpl-abc123"\n object: "chat.completion"\n created: 1677652288\n model: ""\n choices:\n - message:\n role: "assistant"\n content: "The capital of France is Paris."\n index: 0\n finish_reason: "stop"\n logprobs: null\n usage:\n prompt_tokens: 12\n completion_tokens: 8\n total_tokens: 20\n \'400\':\n $ref: \'#/components/responses/BadRequest\'\n \'401\':\n $ref: \'#/components/responses/Unauthorized\'\n \'404\':\n $ref: \'#/components/responses/NotFound\'\n \'409\':\n description: Successful inference result\n content:\n application/json:\n description: Pandas records format response\n schema:\n $ref: \'#/components/responses/Conflict\'\n example:\n code: 409\n status: error\n error: "Inference failed. Please apply the appropriate OpenAI configurations to the models deployed in this pipeline. For additional help contact support@wallaroo.ai or your Wallaroo technical representative."\n source: engine\n \'500\':\n $ref: \'#/components/responses/InternalServerError\'\n \'503\':\n $ref: \'#/components/responses/ServiceUnavailable\'\n\ncomponents:\n securitySchemes:\n BearerAuth:\n type: http\n scheme: bearer\n bearerFormat: JWT\n description: |\n Authentication token obtained through the Wallaroo platform.\n Use the SDK authentication methods to obtain a valid token.\n \n schemas:\n ErrorResponse:\n type: object\n properties:\n code:\n type: integer\n description: HTTP status code\n example: 400\n status:\n type: string\n description: Error status message\n example: "error"\n error:\n type: string\n description: Detailed error message\n example: "Invalid input format"\n source:\n type: string\n description: Source of the error (e.g., engine, sidekick)\n example: "engine"\n required:\n - code\n - error\n \n responses:\n BadRequest:\n description: Invalid request format or parameters\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n examples:\n invalid_tensor:\n summary: Invalid tensor format\n value:\n code: 400\n status: "error"\n error: "tensor values may not be null"\n source: "engine"\n \n Unauthorized:\n description: Authentication required or invalid\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n example:\n code: 401\n status: "error"\n error: "Jwt is missing"\n source: "platform"\n \n NotFound:\n description: Deployment or pipeline not found\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n example:\n code: 404\n status: "error"\n error: "Deployment not found"\n source: "platform"\n \n Conflict:\n description: Endpoint doesn\'t match pipeline type\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n\n InternalServerError:\n description: Internal server error\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n example:\n code: 500\n status: "error"\n error: "Internal processing error"\n source: "engine"\n \n ServiceUnavailable:\n description: Service temporarily unavailable or insufficient resources\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n examples:\n pipeline_being_activated:\n summary: Pipeline being activated\n value:\n code: 503\n status: "error"\n error: "The resources required to run this request are not available. Please check the inference endpoint status and try again"\n source: "engine"\n \n\nsecurity:\n - BearerAuth: []\n\ntags:\n - name: OpenAI Compatibility\n description: OpenAI-compatible completion and chat completion endpoints \n'
WITHOUT_OPENAI = '\nopenapi: 3.1.1\ninfo:\n title: {pipeline_name}\n description: |\n The Wallaroo Inference API allows you to perform real-time inference on deployed machine learning models and pipelines.\n \n ## Supported Data Formats\n \n The API supports multiple input and output formats:\n - **Pandas Records**: JSON format compatible with pandas DataFrame.to_json(orient="records")\n - **Apache Arrow**: Binary format for high-performance data exchange\n \n ## Authentication\n \n All requests require authentication using Bearer tokens obtained through the Wallaroo platform.\n \n version: {version}\n\nservers:\n - url: {url}\n description: Wallaroo API\n\npaths:\n /:\n post:\n summary: Perform inference on a deployed pipeline\n description: |\n Performs inference on a deployed pipeline. The pipeline processes data sequentially\n through a series of steps, where each step\'s output becomes the input for the next step.\n The final output represents the result of the entire pipeline\'s processing.\n \n The request body format and response format depend on the Content-Type header:\n - `application/json; format=pandas-records`: Pandas records format \n - `application/vnd.apache.arrow.file`: Apache Arrow binary format\n \n operationId: runInference\n tags:\n - Native Inference\n parameters:\n - name: dataset[]\n in: query\n required: false\n description: |\n Dataset fields to include in response. Defaults to ["*"] which returns\n ["time", "in", "out", "anomaly", "metadata"].\n schema:\n type: array\n items:\n type: string\n default: ["*"]\n style: form\n explode: true\n example: ["time", "in", "out"]\n - name: dataset.exclude[]\n in: query\n required: false\n description: Dataset fields to exclude from response\n schema:\n type: array\n items:\n type: string\n style: form\n explode: true\n example: ["metadata"]\n - name: dataset.flatten\n in: query\n required: false\n description: |\n Determines whether to flatten nested dataset fields using dot notation.\n schema:\n type: boolean\n default: false\n requestBody:\n required: true\n content:\n application/json; format=pandas-records:\n description: Pandas records format (list of dictionaries)\n schema:\n $ref: \'#/components/schemas/PandasRecordsInput\'\n application/vnd.apache.arrow.file:\n description: Apache Arrow binary format\n schema:\n type: string\n format: binary\n responses:\n \'200\':\n description: Successful inference result\n content:\n application/json; format=pandas-records:\n description: Pandas records format response\n schema:\n $ref: \'#/components/schemas/PandasRecordsOutput\'\n application/vnd.apache.arrow.file:\n description: Apache Arrow binary format response\n schema:\n type: string\n format: binary\n \'400\':\n $ref: \'#/components/responses/BadRequest\'\n \'401\':\n $ref: \'#/components/responses/Unauthorized\'\n \'404\':\n $ref: \'#/components/responses/NotFound\'\n \'409\':\n description: Pipeline type conflict\n content:\n application/json:\n description: Pandas records format response\n schema:\n $ref: \'#/components/responses/Conflict\'\n example:\n code: 409\n status: error\n error: "Inference failed. Please apply the appropriate OpenAI extensions to the inference endpoint. For additional help contact support@wallaroo.ai or your Wallaroo technical representative."\n source: engine\n \'500\':\n $ref: \'#/components/responses/InternalServerError\'\n \'503\':\n $ref: \'#/components/responses/ServiceUnavailable\'\n\n\ncomponents:\n securitySchemes:\n BearerAuth:\n type: http\n scheme: bearer\n bearerFormat: JWT\n description: |\n Authentication token obtained through the Wallaroo platform.\n Use the SDK authentication methods to obtain a valid token.\n \n schemas:\n InferenceInputObject:\n type: object\n description: Object-based input for inference\n additionalProperties: true\n example:\n tensor: [1.0, 2.0, 3.0, 4.0]\n \n InferenceInputArray:\n type: array\n description: Array-based input for inference\n items:\n type: array\n items:\n type: number\n example:\n - [1.0, 2.0, 3.0]\n - [4.0, 5.0, 6.0]\n \n PandasRecordsInput:\n type: array\n items:\n type: object\n {input_schema}\n \n InferenceOutputObject:\n type: object\n description: Object-based output from inference\n additionalProperties: true\n example:\n prediction: [0.95, 0.05]\n confidence: 0.98\n \n InferenceOutputArray:\n type: array\n description: Array-based output from inference\n items:\n type: array\n items:\n type: number\n example:\n - [0.95, 0.05]\n - [0.87, 0.13]\n \n PandasRecordsOutput:\n type: array\n description: Pandas records output format\n items:\n oneOf:\n - type: object\n description: When flatten is `false`\n properties:\n time:\n type: integer\n format: int64\n description: Timestamp of the inference in milliseconds since epoch\n example: 1670564317817\n in:\n $ref: \'#/components/schemas/PandasRecordsInput\'\n out:\n type: object\n {output_schema}\n metadata:\n type: object\n properties:\n last_model:\n type: object\n properties:\n model_name:\n type: string\n model_sha:\n type: string\n pipeline_version:\n type: string\n elapsed:\n type: array\n items:\n type: integer\n format: int64\n dropped:\n type: array\n items:\n type: integer\n format: int64\n partition:\n type: string\n anomaly:\n type: object\n properties:\n count:\n type: integer\n format: int64\n required:\n - time\n - type: Object\n description: When flatten is `true`\n properties:\n time:\n type: integer\n format: int64\n description: Timestamp of the inference in milliseconds since epoch\n example: 1670564317817\n metadata.last_model:\n type: object\n properties:\n model_name:\n type: string\n model_sha:\n type: string\n metadata.pipeline_version:\n type: string\n metadata.elapsed:\n type: array\n items:\n type: integer\n format: int64\n metadata.dropped:\n type: array\n items:\n type: integer\n format: int64\n metadata.partition:\n type: string\n anomaly.count:\n type: integer\n format: int64\n {flattened_input_schema}\n {flattened_output_schema}\n\n\n ErrorResponse:\n type: object\n properties:\n code:\n type: integer\n description: HTTP status code\n example: 400\n status:\n type: string\n description: Error status message\n example: "error"\n error:\n type: string\n description: Detailed error message\n example: "Invalid input format"\n source:\n type: string\n description: Source of the error (e.g., engine, sidekick)\n example: "engine"\n required:\n - code\n - error\n \n responses:\n BadRequest:\n description: Invalid request format or parameters\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n examples:\n invalid_tensor:\n summary: Invalid tensor format\n value:\n code: 400\n status: "error"\n error: "tensor values may not be null"\n source: "engine"\n \n Unauthorized:\n description: Authentication required or invalid\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n example:\n code: 401\n status: "error"\n error: "Jwt is missing"\n source: "platform"\n \n NotFound:\n description: Deployment or pipeline not found\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n example:\n code: 404\n status: "error"\n error: "Deployment not found"\n source: "platform"\n \n Conflict:\n description: Endpoint doesn\'t match pipeline type\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n\n InternalServerError:\n description: Internal server error\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n example:\n code: 500\n status: "error"\n error: "Internal processing error"\n source: "engine"\n \n ServiceUnavailable:\n description: Service temporarily unavailable or insufficient resources\n content:\n application/json:\n schema:\n $ref: \'#/components/schemas/ErrorResponse\'\n examples:\n pipeline_being_activated:\n summary: Pipeline being activated\n value:\n code: 503\n status: "error"\n error: "The resources required to run this request are not available. Please check the inference endpoint status and try again"\n source: "engine"\n\nsecurity:\n - BearerAuth: []\n\ntags:\n - name: Native Inference\n description: Wallaroo\'s native inference API with multiple data format support\n'
DEFAULT_SCHEMA = 'additionalProperties: true'
class NoAliasDumper(yaml.dumper.SafeDumper):
def ignore_aliases(self, data):
def arrow_field_to_openapi(t):
def decode_arrow_schema_from_base64(base64_schema: str) -> pyarrow.lib.Schema:

Decode a base64-encoded Arrow schema.

Args: base64_schema: Base64-encoded serialized Arrow schema string

Returns: PyArrow Schema object

def arrow_schema_to_openapi_yaml(schema: pyarrow.lib.Schema, indent=0, prepend_props='') -> str: