Skip to main content
Get details of a specific code execution context, including current variables and state.

Basic Usage

from gravixlayer import GravixLayer

client = GravixLayer(api_key="YOUR_API_KEY")

# Get a specific context
context = client.sandbox.sandboxes.get_context("your-sandbox-id", context_id="your-context-id")
print(f"Context: {context.name}")
print(f"Language: {context.language}")
print(f"Variables: {context.variables}")

Parameters

ParameterTypeRequiredDescription
sandbox_idstringYesSandbox ID (UUID)
context_idstringYesContext ID (UUID)

Response

{
  "context_id": "ctx_550e8400-e29b-41d4-a716-446655440000",
  "name": "data_analysis",
  "language": "python",
  "created_at": "2025-01-27T10:30:00Z",
  "variables": {
    "df": "pandas.DataFrame",
    "total_rows": 1000,
    "processed": true
  }
}

List All Contexts

Get all contexts in a sandbox:
contexts = client.sandbox.sandboxes.list_contexts("your-sandbox-id")
for ctx in contexts:
    print(f"{ctx.name} ({ctx.language}) - {ctx.context_id}")

Context Management

Use contexts to:
  • Isolate variables: Keep different tasks separate
  • Maintain state: Variables persist between executions
  • Debug code: Inspect current variable values
  • Organize work: Name contexts by purpose

Next Steps

Run Code

Execute code in the context

Create Context

Create new contexts

Delete Context

Clean up unused contexts

Get Sandbox Info

Monitor sandbox status