Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.gravixlayer.ai/llms.txt

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

Code contexts let you preserve variables, imports, and state across multiple run_code calls.
from gravixlayer import GravixLayer

client = GravixLayer()
runtime = client.runtime.create(template="python-3.14-base-small")

ctx = client.runtime.create_context(runtime.runtime_id)
print(ctx.context_id)
print(ctx.language)  # python
print(ctx.cwd)       # /workspace

client.runtime.run_code(runtime.runtime_id, code="counter = 1", context_id=ctx.context_id)
result = client.runtime.run_code(runtime.runtime_id, code="counter += 1\nprint(counter)", context_id=ctx.context_id)
print(result.text)  # 2

runtime.kill()

Parameters

ParameterTypeRequiredDescription
runtime_idstringYesRuntime identifier
languagestringNoContext language. Default: python
cwdstringNoWorking directory. Default: /workspace

Response

FieldTypeDescription
context_idstringContext identifier (pass to run_code)
languagestringLanguage of the context
cwdstringWorking directory