> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ns.rocks/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Choose a supported code interpreter language and kernel.

The standard `code-interpreter` template includes Jupyter kernels for:

* Python
* JavaScript
* TypeScript
* R
* Java
* Bash

Pass `language=` when you run an isolated cell, or set the language on a code
context when you want multiple cells to share kernel state.

<CodeGroup>
  ```python Python SDK theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
  result = machine.run_code("console.log(1 + 2)", language="javascript")
  print("".join(result.logs.stdout))

  ctx = machine.code_interpreter.create_code_context(language="r", cwd="/workspace")
  machine.code_interpreter.run_code("x <- c(1, 2, 3)", context=ctx)
  result = machine.code_interpreter.run_code("mean(x)", context=ctx)
  print(result.results[0].text)
  ```

  ```typescript TypeScript SDK theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
  const result = await machine.code.run("console.log(1 + 2)", { language: "javascript" });
  console.log(result.logs.stdout.join(""));

  const ctx = await machine.code.createContext({ language: "r", cwd: "/workspace" });
  await machine.code.run("x <- c(1, 2, 3)", { context: ctx });
  const r = await machine.code.run("mean(x)", { context: ctx });
  console.log(r.results[0].text);
  ```

  ```bash CLI theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
  nullspace machine code run mch_123 "console.log(1 + 2)" --language javascript

  nullspace machine code context create mch_123 --language r --cwd /workspace
  nullspace machine code run mch_123 "x <- c(1, 2, 3)" --context <context-id>
  nullspace machine code run mch_123 "mean(x)" --context <context-id>
  ```

  ```bash HTTP API theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
  # returns a Server-Sent Events stream of JSON events
  curl -N -X POST "${NULLSPACE_API_URL}/v1/machines/mch_123/code/execute" \
    -H "Authorization: Bearer ${NULLSPACE_API_KEY}" \
    -H "Content-Type: application/json" \
    -d '{"code": "console.log(1 + 2)", "language": "javascript"}'
  # create an R context, then run against its id
  curl -X POST "${NULLSPACE_API_URL}/v1/machines/mch_123/code/contexts" \
    -H "Authorization: Bearer ${NULLSPACE_API_KEY}" \
    -H "Content-Type: application/json" \
    -d '{"language": "r", "cwd": "/workspace"}'
  curl -N -X POST "${NULLSPACE_API_URL}/v1/machines/mch_123/code/execute" \
    -H "Authorization: Bearer ${NULLSPACE_API_KEY}" \
    -H "Content-Type: application/json" \
    -d '{"code": "x <- c(1, 2, 3)", "context_id": "<context-id>"}'
  curl -N -X POST "${NULLSPACE_API_URL}/v1/machines/mch_123/code/execute" \
    -H "Authorization: Bearer ${NULLSPACE_API_KEY}" \
    -H "Content-Type: application/json" \
    -d '{"code": "mean(x)", "context_id": "<context-id>"}'
  ```
</CodeGroup>

## Related

* [Python](./language-python)
* [JavaScript and TypeScript](./language-javascript-typescript)
* [R](./language-r)
* [Java](./language-java)
* [Bash](./language-bash)
