Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.optexity.com/llms.txt

Use this file to discover all available pages before exploring further.

POST /inference

Submits automation tasks to an Optexity inference server for asynchronous execution.

Description

The inference endpoint is the primary way to submit automation tasks to an Optexity inference server. Tasks are enqueued and executed asynchronously in the background. The endpoint supports both local development and cloud production deployments.

Authentication

Local endpoint (http://localhost:9000/inference) does not require authentication and is free to use for development and testing.
Cloud endpoint (https://api.optexity.com/api/v1/inference) requires authentication with an API key in the request header. API keys can be found in the Optexity dashboard under the “API Keys” section. This requires a paid plan. Contact us at founders@optexity.com to get a paid plan.

Parameters

Headers

  • Content-Type string required Must be set to application/json
  • Authorization string required (cloud endpoint only) API key for authentication. Format: x-api-key YOUR_OPTEXITY_API_KEY Not required for local endpoint

Body Parameters

  • endpoint_name string required Name of the automation endpoint to execute. Must match a recording/automation configured in the Optexity control plane.
  • input_parameters dict[str, list[str]] required Input values for the automation. Keys are parameter names, values are lists of strings. Every parameter defined in the automation’s input_parameters should be provided here. If a parameter is given an empty list and it is used in an input text action, the action will be skipped.
  • secure_parameters dict[str, list[SecureParameter]] optional Secure parameters for the automation. Keys are parameter names, values are lists of secure parameters. Every parameter defined in the automation’s secure_parameters should be provided here. These are used to securely store sensitive information like passwords, API keys, and other secrets. Please refer to the Secure Parameters API Reference and One Password Integration documentation for more information.
  • unique_parameter_names list[str] optional Subset of keys from input_parameters that uniquely identify this task. Used for deduplication. Every name in this list must exist as a key in input_parameters.

Code Examples

curl -X POST http://localhost:9000/inference \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint_name": "order-scraper",
    "input_parameters": {
      "username": ["admin@company.com"],
      "password": ["secretpassword"],
      "date_range": ["last-30-days"]
    },
    "unique_parameter_names": ["username", "date_range"]
  }'

Example with Secure Parameters

curl -X POST http://localhost:9000/inference \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint_name": "login-flow",
    "input_parameters": {
      "content": ["This is the content of the page"]
    },
    "secure_parameters": {
      "username": [
        {
          "onepassword": {
            "vault_name": "optexity_automation",
            "item_name": "fedex",
            "field_name": "username"
          }
        }
      ],
      "password": [
        {
          "onepassword": {
            "vault_name": "optexity_automation",
            "item_name": "fedex",
            "field_name": "password"
          }
        }
      ]
    },
    "unique_parameter_names": ["username"]
  }'

Response

Success Response (202 Accepted)

The task has been enqueued and will execute asynchronously.
{
    "success": true,
    "message": "Task has been allocated"
}
Response Fields:
FieldTypeDescription
successbooleanIndicates whether the request was successful
messagestringStatus message describing the result

Error Responses

400 Bad Request

Returned when request parameters are invalid.
{
    "success": false,
    "message": "unique_parameter_names contains key 'username' not found in input_parameters"
}
Common causes:
  • unique_parameter_names contains a key that doesn’t exist in input_parameters
  • Parameter values are not lists of strings
  • Missing required endpoint_name or input_parameters fields

404 Not Found

Returned when the specified endpoint does not exist.
{
    "success": false,
    "message": "Endpoint 'invalid-endpoint' not found"
}
Common causes:
  • endpoint_name doesn’t match any configured automation
  • Endpoint has been deleted or is not accessible

401 Unauthorized

Returned when authentication fails (cloud endpoint only).
{
    "success": false,
    "message": "Invalid or missing API key"
}
Common causes:
  • Missing Authorization header
  • Invalid API key format
  • Expired or revoked API key

500 Internal Server Error

Returned when an unexpected server error occurs.
{
    "success": false,
    "message": "Control plane error: Network issue or invalid API key"
}
Common causes:
  • Network connectivity issues with the control plane
  • Control plane service unavailable
  • Internal server configuration errors

How It Works

  1. The inference server receives the InferenceRequest
  2. It forwards the request to the Optexity control plane at api.optexity.com
  3. The control plane returns a serialized Task object containing the full workflow
  4. The task is enqueued locally for background execution
  5. A 202 Accepted response is returned immediately
  6. The browser automation executes asynchronously

Validation

The endpoint validates:
  1. All unique_parameter_names exist in input_parameters
  2. All parameter values are lists of strings
  3. The endpoint_name matches a valid automation

Configuration

The endpoint uses these settings from environment variables:
SettingDefaultDescription
OPTEXITY_API_KEYRequiredAPI key for control plane authentication
INFERENCE_ENDPOINTapi/v1/inferenceControl plane endpoint path
The control plane returns a Task object with this structure:
class Task:
    task_id: str                          # Unique identifier
    user_id: str                          # Owner of the task
    recording_id: str                     # Source automation ID
    automation: Automation                # Full workflow
    input_parameters: dict[str, list[str]]
    unique_parameter_names: list[str]
    unique_parameters: dict[str, list[str]] | None

    # Lifecycle
    created_at: datetime
    allocated_at: datetime | None
    started_at: datetime | None
    completed_at: datetime | None
    status: "queued" | "allocated" | "running" | "success" | "failed" | "cancelled"
    error: str | None

    # Retry configuration
    retry_count: int = 0
    max_retries: int = 1

    # Storage paths
    save_directory: Path
    task_directory: Path | None
    logs_directory: Path | None
    downloads_directory: Path | None
    log_file_path: Path | None

    # Deduplication
    dedup_key: str

    # Authentication
    api_key: str