Skip to main content

Grid Cortex Client

PyPI version Python

Python client for GRID Cortex.

Installation

pip install grid-cortex-client

Quick Start

from grid_cortex_client import CortexClient, ModelType

client = CortexClient(api_key="your-api-key")

# Monocular depth estimation
depth_map = client.run(ModelType.ZOEDEPTH, image_input="path/to/image.jpg")

Configuration

Pass your API key and base URL directly, or set them as environment variables:

export GRID_CORTEX_API_KEY="your-api-key"
export GRID_CORTEX_BASE_URL="https://cortex-prod.generalrobotics.dev/cortex"
# Explicit configuration
client = CortexClient(api_key="your-key", base_url="https://...")

# Or rely on environment variables
client = CortexClient()

Input Formats

All image-based models accept multiple input types:

  • File path: "path/to/image.jpg"
  • URL: "https://example.com/image.jpg"
  • PIL Image: Image.open("image.jpg")
  • NumPy array: np.ndarray with shape (H, W, 3)

Async & Concurrent Inference

The async client lets you call multiple models concurrently so total latency equals the slowest model, not the sum of all of them.

Concurrent multi-model example

import asyncio
import numpy as np
from grid_cortex_client import AsyncCortexClient, ModelType

async def run_perception_pipeline(image: np.ndarray):
    """Run depth, detection, and segmentation concurrently on the same frame."""
    async with AsyncCortexClient() as client:
        depth, detections, mask = await asyncio.gather(
            client.run(ModelType.ZOEDEPTH, image_input=image),
            client.run(ModelType.OWLV2, image_input=image, prompt="bottle"),
            client.run(ModelType.GSAM2, image_input=image, prompt="bottle"),
        )
    return depth, detections, mask

depth, detections, mask = asyncio.run(
    run_perception_pipeline(np.array(Image.open("scene.jpg")))
)

High-throughput streaming with pub/sub

For continuous streams (e.g. camera feeds), the CortexHubClient uses WebSockets to overlap sending and receiving. While frame N's result is being returned, frame N+1 is already being processed server-side:

import asyncio
import numpy as np
from grid_cortex_client import CortexHubClient, ModelType

async def publisher(hub: CortexHubClient, frames: list[np.ndarray]):
    """Send frames as fast as possible."""
    for i, frame in enumerate(frames):
        await hub.publish(ModelType.ZOEDEPTH, request_id=f"frame_{i}", image_input=frame)

async def subscriber(hub: CortexHubClient, num_frames: int):
    """Receive results as they arrive."""
    count = 0
    async for result in hub.subscribe():
        if result.ok:
            print(f"{result.request_id}: shape={result.data.shape}")
        count += 1
        if count >= num_frames:
            break

async def main():
    frames = [np.random.randint(0, 255, (480, 640, 3), dtype=np.uint8)] * 100

    async with CortexHubClient() as hub:
        await asyncio.gather(
            publisher(hub, frames),
            subscriber(hub, len(frames)),
        )

asyncio.run(main())

Documentation

For model-specific usage examples, parameter references, and detailed guides, see the full documentation:

docs.generalrobotics.dev/models/cortex

Requirements

  • Python >= 3.8

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grid_cortex_client-0.6.1.tar.gz (82.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grid_cortex_client-0.6.1-py3-none-any.whl (77.5 kB view details)

Uploaded Python 3

File details

Details for the file grid_cortex_client-0.6.1.tar.gz.

File metadata

  • Download URL: grid_cortex_client-0.6.1.tar.gz
  • Upload date:
  • Size: 82.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for grid_cortex_client-0.6.1.tar.gz
Algorithm Hash digest
SHA256 1a9565e40385927730365a0025f908818b5bff727dbbbd9575b5db59e7526567
MD5 682aa3ae2907e7dea8b9e68bc332ee0e
BLAKE2b-256 5f81a333611aa778a2f869435b141988cb540befe6fb78cc7aa9e4347518d5e4

See more details on using hashes here.

File details

Details for the file grid_cortex_client-0.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for grid_cortex_client-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a6af82e0e69763b108b53c79c30f389a4b9a244a4e9431b72168defb20c55a5
MD5 bc29c417083481288da0c2b05fa708f5
BLAKE2b-256 9a5b40d68081a31229d0b5d8bc8fb36bb3e22746f5c7d9795414db671c04ab9c

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.0

1 file

1.1.0

1 file

1.0.9

1 file

1.0.8

1 file

1.0.7

1 file

1.0.6

1 file

This release

0.6.1 This release

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.118

1 file

0.2.117

1 file

0.2.110

1 file

0.2.109

1 file

0.2.83

1 file

0.2.52

1 file

0.2.43

1 file

0.2.25

1 file

0.2.9

1 file

0.2.4

1 file

0.2.3

1 file

0.1.273

1 file

0.1.265

1 file

0.1.264

1 file

0.1.263

1 file

0.1.262

1 file

0.1.261

1 file

0.1.255

1 file

0.1.244

1 file

0.1.228

1 file

0.1.221

1 file

0.1.150

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page