Skip to main content
The CodeExecutionRequest model represents the payload sent to the code execution endpoint. It contains the code snippet and the programming language specification.

Fields

code
string
required
The source code to be executed. This can be a complete program or a code snippet depending on the language requirements.
language
string
required
The programming language of the code. Supported values include:
  • java - Java programming language
  • python - Python programming language
  • c - C programming language
  • cpp - C++ programming language
  • javascript - JavaScript (Node.js) programming language

Example

{
  "code": "print('Hello, World!')",
  "language": "python"
}

Java class

This model is defined in the backend as:
package com.runtime.model;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class CodeExecutionRequest {
    private String code;
    private String language;
}

Usage

The CodeExecutionRequest is used as the request body when calling the /api/execute endpoint. See the Execute Code endpoint documentation for more details.
Ensure the code is properly escaped when sending as JSON. Special characters like quotes and newlines must be properly formatted.

Build docs developers (and LLMs) love