> ## 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.

# Create Context

> Create persistent code execution contexts to preserve state across calls

Code contexts let you preserve variables, imports, and state across multiple `run_code` calls.

```python theme={null}
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

| Parameter    | Type   | Required | Description                              |
| ------------ | ------ | -------- | ---------------------------------------- |
| `runtime_id` | string | Yes      | Runtime identifier                       |
| `language`   | string | No       | Context language. Default: `python`      |
| `cwd`        | string | No       | Working directory. Default: `/workspace` |

## Response

| Field        | Type   | Description                             |
| ------------ | ------ | --------------------------------------- |
| `context_id` | string | Context identifier (pass to `run_code`) |
| `language`   | string | Language of the context                 |
| `cwd`        | string | Working directory                       |
