Skip to main content
Client for interacting with Grid Cortex Ray Serve deployments.

Constructor

Initializes the CortexClient.
API key. Uses GRID_CORTEX_API_KEY env var if None.
Base URL of the Cortex API. If None, uses GRID_CORTEX_BASE_URL env var or HTTPClient’s default.
default:"30.0"
Default timeout for HTTP requests in seconds.

Methods

available_models()

Return all registered model identifiers. This method provides a complete list of all available models that can be used with the CortexClient. Essential for LLM agents to discover what models are available before attempting to use them. Returns: A sorted list of model identifiers (e.g., [“gsam2”, “owlv2”, “zoedepth”]). These strings can be used directly with run and help.

close()

Closes the underlying HTTP client.

get_info()

Get Grid-Cortex server version and deployed models status. Fetches real-time information about the Cortex deployment including version and current model replica counts. Returns: Dictionary containing:
  • version (str): Grid-Cortex version (e.g., “v0.2.49”)
  • models (list): List of deployed models with:
    • name (str): Model identifier
    • status (str): Deployment status (“RUNNING”, etc.)
    • route (str): HTTP route prefix
    • replicas (int): Number of running replicas
Raises: CortexAPIError: If the API returns an error. CortexNetworkError: If network communication fails.

help()

Return comprehensive documentation for a model. This method provides complete API documentation for any registered model, including usage examples, parameter descriptions, return types, and error conditions. Essential for LLM agents to understand how to interact with specific models before calling run.
required
Canonical model identifier (e.g., “zoedepth”, “owlv2”, “gsam2”).
Returns: A formatted string containing:
  • Class-level docstring with usage examples and parameter descriptions
  • Preprocess method documentation (input parameters and validation)
  • Postprocess method documentation (output format and data types)
Raises: NotImplementedError: If model_id is not registered or not found.

run()

Execute inference using a specified model with given inputs. This is the primary method for running AI model inference. It automatically handles model discovery, input preprocessing, API communication, and output postprocessing. Essential for LLM agents to perform actual model inference after discovering available models and understanding their requirements.
required
The identifier of the model to run (use available_models to see all available options). Examples: “zoedepth”, “owlv2”, “gsam2”.
Optional timeout in seconds for the HTTP request. If None, uses the client’s default timeout.
default:"False"
If True, enables detailed logging for this specific call to help troubleshoot issues.
default:"False"
If True, returns the raw API response without postprocessing.
Model-specific input parameters. Each model’s page in the Cortex Models docs section and help document its exact inputs.
Returns: The model’s postprocessed output; the concrete type is model-specific. Per-model inputs, output types, and worked examples live on the model pages in the Cortex Models docs section — generated from each model wrapper’s docstring, the canonical source — and via help. Raises: NotImplementedError: If model_id is not found in available models. CortexAPIError: If the API returns an error response. CortexNetworkError: If network communication fails. ValueError: If input validation or processing fails.

run_with_detections()

Like run, but returns per-instance detections (currently SAM3 text/box prompts).