---
title: "Code Execution"
method: POST
path: "/v1/code/execute"
tags: ["Suprsonic"]
---

# Code Execution

`POST /v1/code/execute`

## Request

- Base URL: `https://suprsonic.ai`
- URL: `https://suprsonic.ai/v1/code/execute`
- Auth: HTTP bearer

Execute code in a secure sandbox with pre-configured environments. Returns stdout, stderr, the exit code, the run time, and the files the code wrote to /home/user/output/ as base64. Use for calculations, data processing and running scripts. Each call runs in a fresh sandbox that is destroyed afterwards, so nothing carries over from one call to the next. Cost: 2 credits, charged only when a call succeeds.

## Request body

- CodeExecuteRequest: Execute code in an isolated sandbox.
  - `code` string, required: The code to execute
  - `language` string: Programming language: python, javascript, or shell
  - `timeout` integer: Maximum execution time in seconds (1-300)
  - `template` string, nullable: Pre-configured environment: default, data-science, web-dev, video
  - `input_files` InputFile[]: Files to upload to the sandbox before execution
    - `name` string, required: Filename (e.g. 'data.csv')
    - `content` string, required: Base64-encoded file content
  - `packages` string[]: Additional pip packages to install before execution

## Response `200`

The call's envelope: success, data (the capability's result), metadata, and credits_used (0 when the call did not succeed).

- UnifiedResponse: Standard envelope for all unified API responses.
  - `success` boolean, required
  - `data` union
    - object
    - unknown[]
      - unknown
  - `error` UnifiedError: RFC 7807 problem detail for machine-actionable errors.
    - `type` string, required
    - `title` string, required
    - `status` integer, required
    - `detail` string, nullable
    - `is_retriable` boolean
    - `retry_after_seconds` integer, nullable
    - `alternative_action` string, nullable
    - `error_category` string
    - `caller_error` string, nullable
  - `metadata` UnifiedMetadata: Metadata included in every unified API response.
    - `provider_used` string, nullable
    - `providers_tried` string[]
    - `mode_used` string, nullable
    - `response_time_ms` integer
    - `request_id` string
    - `capability` string, nullable
    - `params` object, nullable
  - `credits_used` integer

## Other responses

- `401`: No API key, or one that was not found or is revoked.
- `402`: Not enough credits for this call. The error's alternative_action says where to add them.
- `403`: The account is restricted by a billing issue.
- `422`: Validation Error
- `429`: The key's rate limit is reached. The error's retry_after_seconds says when to try again.

---

[API](https://skmtc.dev/o-mega/apis/suprsonic-api.md) - [All operations](https://skmtc.dev/o-mega/apis/suprsonic-api/llms.txt) - [OpenAPI document](https://skmtc.dev/o-mega/apis/suprsonic-api/revisions/0eb535eb5679?raw)
