Skip to content

Client SDK Python

Dmitrii Karataev edited this page Feb 26, 2026 · 3 revisions

Client SDK -- Python

The rocketride Python SDK provides an async client for connecting to RocketRide Engine, executing pipelines, sending data, and chatting with AI.

Installation

From PyPI:

pip install rocketride

Or download directly from a running engine:

GET http://<engine-host>:<port>/client/python

Dependencies

  • websockets >= 11.0.0
  • aiofiles >= 23.0.0
  • pydantic >= 2.0.0
  • Python 3.9+

Quick Example

from rocketride import RocketRideClient, Question

async with RocketRideClient(uri='http://localhost:5565', auth='your-api-key') as client:
    result = await client.use(filepath='pipeline.json')

    question = Question()
    question.addQuestion('Summarize this document')
    answer = await client.chat(token=result['token'], question=question)
    print(answer)

Constructor

RocketRideClient(uri='', auth='', **kwargs)
Parameter Type Default Description
uri str ROCKETRIDE_URI env Server URI (http/https/ws/wss)
auth str ROCKETRIDE_APIKEY env API key for authentication
env dict .env file Environment variables for config and pipeline substitution
persist bool False Enable automatic reconnection with exponential backoff
request_timeout int None Default timeout (ms) for individual requests
max_retry_time int None Max total time (ms) to keep retrying connections
module str None Custom module name for client identification

HTTP/HTTPS URIs are automatically upgraded to WebSocket (ws/wss).

Context Manager

The recommended pattern uses async with for automatic connection management:

async with RocketRideClient(uri='http://localhost:5565', auth='key') as client:
    # client is connected here
    pass
# client is automatically disconnected

Or manage the connection manually:

client = RocketRideClient(uri='http://localhost:5565', auth='key')
await client.connect()
try:
    # your operations
    pass
finally:
    await client.disconnect()

Methods

Connection

await client.connect(timeout=None)
await client.disconnect()
await client.ping(token=None)

Pipeline Execution

# Load and start a pipeline
result = await client.use(
    filepath='pipeline.json',  # Path to pipeline JSON
    # OR
    pipeline={...},            # Inline pipeline definition
    env={...},                 # Optional environment variables
)

# Check pipeline status
status = await client.get_task_status(token)

# Stop a running pipeline
await client.terminate(token)

Data Operations

# Send text data
result = await client.send(token, data, mime_type=None, provider=None)

# Send files
result = await client.send_files(token, files=['/path/to/file.pdf'], provider=None)

# Stream data via a pipe (for large datasets)
pipe = await client.pipe(token, objinfo={}, mime_type=None, provider=None)
await pipe.open()
await pipe.write(b'raw bytes here')
result = await pipe.close()

Chat

from rocketride import Question

question = Question()
question.addQuestion('What are the key findings?')

answer = await client.chat(token=result['token'], question=question)

With conversation history:

question = Question()
question.addQuestion('Follow up on the previous answer')
question.addHistory({'role': 'user', 'content': 'Previous question'})
question.addHistory({'role': 'assistant', 'content': 'Previous answer'})

answer = await client.chat(token=token, question=question)

Events

# Subscribe to event types
await client.set_events(token, event_types=['status', 'task'])

Services

# List available services on the server
services = await client.get_services()

Exported Classes and Types

The package exports the following from its top-level namespace:

Client:

  • RocketRideClient -- main client class
  • RocketRideException -- base exception
  • AuthenticationException -- authentication failure

Schema:

  • Question, QuestionText, QuestionType, QuestionExample, QuestionHistory
  • Answer
  • Doc, DocFilter, DocMetadata, DocGroup

Types:

  • RocketRideClientConfig, ConnectionInfo, DAPMessage
  • ConnectCallback, DisconnectCallback, ConnectErrorCallback, EventCallback
  • PIPELINE_RESULT, UPLOAD_RESULT, TASK_STATUS, TASK_STATE
  • PipelineComponent, PipelineConfig, TraceInfo

Environment Variables

Variable Purpose
ROCKETRIDE_URI Default server URI
ROCKETRIDE_APIKEY Default API key

These are loaded from the process environment or a .env file in the current directory. Constructor parameters override environment variables.

CLI

The package includes a rocketride command-line tool:

rocketride --help

Next Steps

Clone this wiki locally